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