OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 class MediaOptimization; | 26 class MediaOptimization; |
27 } // namespace media_optimization | 27 } // namespace media_optimization |
28 | 28 |
29 struct EncoderParameters { | 29 struct EncoderParameters { |
30 uint32_t target_bitrate; | 30 uint32_t target_bitrate; |
31 uint8_t loss_rate; | 31 uint8_t loss_rate; |
32 int64_t rtt; | 32 int64_t rtt; |
33 uint32_t input_frame_rate; | 33 uint32_t input_frame_rate; |
34 }; | 34 }; |
35 | 35 |
36 /*************************************/ | |
37 /* VCMEncodeFrameCallback class */ | |
38 /***********************************/ | |
39 class VCMEncodedFrameCallback : public EncodedImageCallback { | 36 class VCMEncodedFrameCallback : public EncodedImageCallback { |
40 public: | 37 public: |
41 explicit VCMEncodedFrameCallback( | 38 explicit VCMEncodedFrameCallback(EncodedImageCallback* post_encode_callback); |
42 EncodedImageCallback* post_encode_callback); | 39 virtual ~VCMEncodedFrameCallback(); |
43 virtual ~VCMEncodedFrameCallback(); | |
44 | 40 |
45 /* | 41 // Implements EncodedImageCallback. |
46 * Callback implementation - codec encode complete | 42 int32_t Encoded(const EncodedImage& encoded_image, |
47 */ | 43 const CodecSpecificInfo* codec_specific, |
48 int32_t Encoded( | 44 const RTPFragmentationHeader* fragmentation_header) override; |
49 const EncodedImage& encodedImage, | 45 int32_t SetTransportCallback(VCMPacketizationCallback* transport); |
50 const CodecSpecificInfo* codecSpecificInfo = NULL, | 46 void SetMediaOpt(media_optimization::MediaOptimization* media_opt); |
51 const RTPFragmentationHeader* fragmentationHeader = NULL); | 47 void SetPayloadType(uint8_t payload_type) { payload_type_ = payload_type; } |
52 /* | 48 void SetInternalSource(bool internal_source) { |
53 * Callback implementation - generic encoder encode complete | 49 internal_source_ = internal_source; |
54 */ | 50 } |
55 int32_t SetTransportCallback(VCMPacketizationCallback* transport); | 51 void SetRotation(VideoRotation rotation) { rotation_ = rotation; } |
56 /** | 52 void SignalLastEncoderImplementationUsed( |
57 * Set media Optimization | 53 const char* encoder_implementation_name); |
58 */ | |
59 void SetMediaOpt(media_optimization::MediaOptimization* mediaOpt); | |
60 | |
61 void SetPayloadType(uint8_t payloadType) { | |
62 _payloadType = payloadType; | |
63 } | |
64 | |
65 void SetInternalSource(bool internalSource) { | |
66 _internalSource = internalSource; | |
67 } | |
68 | |
69 void SetRotation(VideoRotation rotation) { _rotation = rotation; } | |
70 void SignalLastEncoderImplementationUsed( | |
71 const char* encoder_implementation_name); | |
72 | 54 |
73 private: | 55 private: |
74 VCMPacketizationCallback* send_callback_; | 56 VCMPacketizationCallback* send_callback_; |
75 media_optimization::MediaOptimization* _mediaOpt; | 57 media_optimization::MediaOptimization* media_opt_; |
76 uint8_t _payloadType; | 58 uint8_t payload_type_; |
77 bool _internalSource; | 59 bool internal_source_; |
78 VideoRotation _rotation; | 60 VideoRotation rotation_; |
79 | 61 |
80 EncodedImageCallback* post_encode_callback_; | 62 EncodedImageCallback* post_encode_callback_; |
| 63 }; |
81 | 64 |
82 #ifdef DEBUG_ENCODER_BIT_STREAM | |
83 FILE* _bitStreamAfterEncoder; | |
84 #endif | |
85 }; // end of VCMEncodeFrameCallback class | |
86 | |
87 /******************************/ | |
88 /* VCMGenericEncoder class */ | |
89 /******************************/ | |
90 class VCMGenericEncoder { | 65 class VCMGenericEncoder { |
91 friend class VCMCodecDataBase; | 66 friend class VCMCodecDataBase; |
92 | 67 |
93 public: | 68 public: |
94 VCMGenericEncoder(VideoEncoder* encoder, | 69 VCMGenericEncoder(VideoEncoder* encoder, |
95 VideoEncoderRateObserver* rate_observer, | 70 VideoEncoderRateObserver* rate_observer, |
96 VCMEncodedFrameCallback* encoded_frame_callback, | 71 VCMEncodedFrameCallback* encoded_frame_callback, |
97 bool internalSource); | 72 bool internal_source); |
98 ~VCMGenericEncoder(); | 73 ~VCMGenericEncoder(); |
99 /** | |
100 * Free encoder memory | |
101 */ | |
102 int32_t Release(); | 74 int32_t Release(); |
103 /** | |
104 * Initialize the encoder with the information from the VideoCodec | |
105 */ | |
106 int32_t InitEncode(const VideoCodec* settings, | 75 int32_t InitEncode(const VideoCodec* settings, |
107 int32_t numberOfCores, | 76 int32_t number_of_cores, |
108 size_t maxPayloadSize); | 77 size_t max_payload_size); |
109 /** | 78 int32_t Encode(const VideoFrame& frame, |
110 * Encode raw image | 79 const CodecSpecificInfo* codec_specific, |
111 * inputFrame : Frame containing raw image | 80 const std::vector<FrameType>& frame_types); |
112 * codecSpecificInfo : Specific codec data | |
113 * cameraFrameRate : Request or information from the remote side | |
114 * frameType : The requested frame type to encode | |
115 */ | |
116 int32_t Encode(const VideoFrame& inputFrame, | |
117 const CodecSpecificInfo* codecSpecificInfo, | |
118 const std::vector<FrameType>& frameTypes); | |
119 | 81 |
120 void SetEncoderParameters(const EncoderParameters& params); | 82 void SetEncoderParameters(const EncoderParameters& params); |
121 EncoderParameters GetEncoderParameters() const; | 83 EncoderParameters GetEncoderParameters() const; |
122 | 84 |
123 int32_t SetPeriodicKeyFrames(bool enable); | 85 int32_t SetPeriodicKeyFrames(bool enable); |
124 | |
125 int32_t RequestFrame(const std::vector<FrameType>& frame_types); | 86 int32_t RequestFrame(const std::vector<FrameType>& frame_types); |
126 | |
127 bool InternalSource() const; | 87 bool InternalSource() const; |
128 | |
129 void OnDroppedFrame(); | 88 void OnDroppedFrame(); |
130 | |
131 bool SupportsNativeHandle() const; | 89 bool SupportsNativeHandle() const; |
132 | |
133 int GetTargetFramerate(); | 90 int GetTargetFramerate(); |
134 | 91 |
135 private: | 92 private: |
136 VideoEncoder* const encoder_; | 93 VideoEncoder* const encoder_; |
137 VideoEncoderRateObserver* const rate_observer_; | 94 VideoEncoderRateObserver* const rate_observer_; |
138 VCMEncodedFrameCallback* const vcm_encoded_frame_callback_; | 95 VCMEncodedFrameCallback* const vcm_encoded_frame_callback_; |
139 const bool internal_source_; | 96 const bool internal_source_; |
140 rtc::CriticalSection params_lock_; | 97 rtc::CriticalSection params_lock_; |
141 EncoderParameters encoder_params_ GUARDED_BY(params_lock_); | 98 EncoderParameters encoder_params_ GUARDED_BY(params_lock_); |
142 VideoRotation rotation_; | 99 VideoRotation rotation_; |
143 bool is_screenshare_; | 100 bool is_screenshare_; |
144 }; // end of VCMGenericEncoder class | 101 }; |
145 | 102 |
146 } // namespace webrtc | 103 } // namespace webrtc |
147 | 104 |
148 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ | 105 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_ENCODER_H_ |
OLD | NEW |