blob: 369d6b81507656fb0418d31b22f1f9144df82cc8 [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_FRAMEENCRYPTORINTERFACE_H_
12#define API_CRYPTO_FRAMEENCRYPTORINTERFACE_H_
13
14#include "api/array_view.h"
15#include "api/mediatypes.h"
16#include "rtc_base/refcount.h"
17
18namespace webrtc {
19
20// FrameEncryptorInterface allows users to provide a custom encryption
21// implementation to encrypt all outgoing audio and video frames. The user must
22// also provide a FrameDecryptorInterface to be able to decrypt the frames on
23// the receiving device. Note this is an additional layer of encryption in
24// addition to the standard SRTP mechanism and is not intended to be used
25// without it. Implementations of this interface will have the same lifetime as
26// the RTPSenders it is attached to.
27// This interface is not ready for production use.
28class FrameEncryptorInterface : public rtc::RefCountInterface {
29 public:
Benjamin Wrightd81ac952018-08-29 17:02:10 -070030 ~FrameEncryptorInterface() override {}
Benjamin Wrightea086912018-08-29 13:06:15 -070031
32 // Attempts to encrypt the provided frame. You may assume the encrypted_frame
33 // will match the size returned by GetOutputSize for a give frame. You may
34 // assume that the frames will arrive in order if SRTP is enabled. The ssrc
35 // will simply identify which stream the frame is travelling on.
36 // TODO(benwright) integrate error codes.
37 virtual bool Encrypt(cricket::MediaType media_type,
38 uint32_t ssrc,
39 rtc::ArrayView<const uint8_t> frame,
40 rtc::ArrayView<uint8_t> encrypted_frame) = 0;
41
42 // Returns the total required length in bytes for the output of the
43 // encryption.
44 virtual size_t GetOutputSize(cricket::MediaType media_type,
45 size_t frame_size) = 0;
46};
47
48} // namespace webrtc
49
50#endif // API_CRYPTO_FRAMEENCRYPTORINTERFACE_H_