blob: 6d57d9264b9b4a69fe076eb8ab677efb46a237e4 [file] [log] [blame]
pbos@webrtc.orgab990ae2014-09-17 09:02:25 +00001/*
2 * Copyright (c) 2014 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 WEBRTC_VIDEO_ENCODER_H_
12#define WEBRTC_VIDEO_ENCODER_H_
13
14#include <vector>
15
16#include "webrtc/typedefs.h"
17#include "webrtc/video_frame.h"
18
19namespace webrtc {
20
21class RTPFragmentationHeader;
22// TODO(pbos): Expose these through a public (root) header or change these APIs.
23struct CodecSpecificInfo;
24struct VideoCodec;
25
26class EncodedImageCallback {
27 public:
28 virtual ~EncodedImageCallback() {}
29
30 // Callback function which is called when an image has been encoded.
31 // TODO(pbos): Make encoded_image const or pointer. Remove default arguments.
32 virtual int32_t Encoded(
33 EncodedImage& encoded_image,
34 const CodecSpecificInfo* codec_specific_info = NULL,
35 const RTPFragmentationHeader* fragmentation = NULL) = 0;
36};
37
38class VideoEncoder {
39 public:
40 enum EncoderType {
41 kVp8,
42 };
43
44 static VideoEncoder* Create(EncoderType codec_type);
45
46 virtual ~VideoEncoder() {}
47
48 virtual int32_t InitEncode(const VideoCodec* codec_settings,
49 int32_t number_of_cores,
50 uint32_t max_payload_size) = 0;
51 virtual int32_t RegisterEncodeCompleteCallback(
52 EncodedImageCallback* callback) = 0;
53 virtual int32_t Release() = 0;
54
55
56 virtual int32_t Encode(const I420VideoFrame& frame,
57 const CodecSpecificInfo* codec_specific_info,
58 const std::vector<VideoFrameType>* frame_types) = 0;
59
60 virtual int32_t SetChannelParameters(uint32_t packet_loss, int rtt) = 0;
61 virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) = 0;
62
63 virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; }
64 virtual int32_t CodecConfigParameters(uint8_t* /*buffer*/, int32_t /*size*/) {
65 return -1;
66 }
67};
68
69} // namespace webrtc
70#endif // WEBRTC_VIDEO_ENCODER_H_