blob: 7a3668594dd728200751527321d7be663ad1ef2c [file] [log] [blame]
Benjamin Wrightea086912018-08-29 13:06:15 -07001/*
2 * Copyright 2018 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef API_CRYPTO_FRAMEDECRYPTORINTERFACE_H_
12#define API_CRYPTO_FRAMEDECRYPTORINTERFACE_H_
13
14#include "api/array_view.h"
15#include "api/mediatypes.h"
16#include "rtc_base/refcount.h"
17
18namespace webrtc {
19
20// FrameDecryptorInterface allows users to provide a custom decryption
21// implementation for all incoming audio and video frames. The user must also
22// provide a FrameEncryptorInterface to be able to encrypt the frames being
23// sent out of the device. Note this is an additional layer of encyrption in
24// addition to the standard SRTP mechanism and is not intended to be used
25// without it. You may assume that this interface will have the same lifetime
26// as the RTPReceiver it is attached to. It must only be attached to one
27// RTPReceiver.
28// Note:
29// This interface is not ready for production use.
30class FrameDecryptorInterface : public rtc::RefCountInterface {
31 public:
32 virtual ~FrameDecryptorInterface() {}
33
34 // Attempts to decrypt the encrypted frame. You may assume the frame size will
35 // be allocated to the size returned from GetOutputSize. You may assume that
36 // the frames are in order if SRTP is enabled. The stream is not provided here
37 // and it is up to the implementor to transport this information to the
38 // receiver if they care about it.
39 // TODO(benwright) integrate error codes
40 virtual bool Decrypt(cricket::MediaType media_type,
41 rtc::ArrayView<const uint8_t> encrypted_frame,
42 rtc::ArrayView<uint8_t> frame) = 0;
43
44 // Returns the total required length in bytes for the output of the
45 // decryption.
46 virtual size_t GetOutputSize(cricket::MediaType media_type,
47 size_t encrypted_frame_size) = 0;
48};
49
50} // namespace webrtc
51
52#endif // API_CRYPTO_FRAMEDECRYPTORINTERFACE_H_