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 |
11 #include "webrtc/modules/video_coding/video_coding_impl.h" | 11 #include "webrtc/modules/video_coding/video_coding_impl.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <utility> | |
15 | 14 |
16 #include "webrtc/common_types.h" | 15 #include "webrtc/common_types.h" |
17 #include "webrtc/common_video/include/video_bitrate_allocator.h" | |
18 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 16 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
19 #include "webrtc/base/criticalsection.h" | 17 #include "webrtc/base/criticalsection.h" |
20 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" | |
21 #include "webrtc/modules/video_coding/include/video_codec_initializer.h" | |
22 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 18 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
23 #include "webrtc/modules/video_coding/encoded_frame.h" | 19 #include "webrtc/modules/video_coding/encoded_frame.h" |
24 #include "webrtc/modules/video_coding/jitter_buffer.h" | 20 #include "webrtc/modules/video_coding/jitter_buffer.h" |
25 #include "webrtc/modules/video_coding/packet.h" | 21 #include "webrtc/modules/video_coding/packet.h" |
26 #include "webrtc/system_wrappers/include/clock.h" | 22 #include "webrtc/system_wrappers/include/clock.h" |
27 | 23 |
28 namespace webrtc { | 24 namespace webrtc { |
29 namespace vcm { | 25 namespace vcm { |
30 | 26 |
31 int64_t VCMProcessTimer::Period() const { | 27 int64_t VCMProcessTimer::Period() const { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 97 } |
102 | 98 |
103 void Process() override { | 99 void Process() override { |
104 sender_.Process(); | 100 sender_.Process(); |
105 receiver_.Process(); | 101 receiver_.Process(); |
106 } | 102 } |
107 | 103 |
108 int32_t RegisterSendCodec(const VideoCodec* sendCodec, | 104 int32_t RegisterSendCodec(const VideoCodec* sendCodec, |
109 uint32_t numberOfCores, | 105 uint32_t numberOfCores, |
110 uint32_t maxPayloadSize) override { | 106 uint32_t maxPayloadSize) override { |
111 if (sendCodec != nullptr && sendCodec->codecType == kVideoCodecVP8) { | |
112 // Set up a rate allocator and temporal layers factory for this vp8 | |
113 // instance. The codec impl will have a raw pointer to the TL factory, | |
114 // and will call it when initializing. Since this can happen | |
115 // asynchronously keep the instance alive until destruction or until a | |
116 // new send codec is registered. | |
117 VideoCodec vp8_codec = *sendCodec; | |
118 std::unique_ptr<TemporalLayersFactory> tl_factory( | |
119 new TemporalLayersFactory()); | |
120 vp8_codec.VP8()->tl_factory = tl_factory.get(); | |
121 rate_allocator_ = VideoCodecInitializer::CreateBitrateAllocator( | |
122 vp8_codec, std::move(tl_factory)); | |
123 return sender_.RegisterSendCodec(&vp8_codec, numberOfCores, | |
124 maxPayloadSize); | |
125 } | |
126 return sender_.RegisterSendCodec(sendCodec, numberOfCores, maxPayloadSize); | 107 return sender_.RegisterSendCodec(sendCodec, numberOfCores, maxPayloadSize); |
127 } | 108 } |
128 | 109 |
129 int32_t RegisterExternalEncoder(VideoEncoder* externalEncoder, | 110 int32_t RegisterExternalEncoder(VideoEncoder* externalEncoder, |
130 uint8_t payloadType, | 111 uint8_t payloadType, |
131 bool internalSource) override { | 112 bool internalSource) override { |
132 sender_.RegisterExternalEncoder(externalEncoder, payloadType, | 113 sender_.RegisterExternalEncoder(externalEncoder, payloadType, |
133 internalSource); | 114 internalSource); |
134 return 0; | 115 return 0; |
135 } | 116 } |
136 | 117 |
137 int Bitrate(unsigned int* bitrate) const override { | 118 int Bitrate(unsigned int* bitrate) const override { |
138 return sender_.Bitrate(bitrate); | 119 return sender_.Bitrate(bitrate); |
139 } | 120 } |
140 | 121 |
141 int FrameRate(unsigned int* framerate) const override { | 122 int FrameRate(unsigned int* framerate) const override { |
142 return sender_.FrameRate(framerate); | 123 return sender_.FrameRate(framerate); |
143 } | 124 } |
144 | 125 |
145 int32_t SetChannelParameters(uint32_t target_bitrate, // bits/s. | 126 int32_t SetChannelParameters(uint32_t target_bitrate, // bits/s. |
146 uint8_t lossRate, | 127 uint8_t lossRate, |
147 int64_t rtt) override { | 128 int64_t rtt) override { |
148 return sender_.SetChannelParameters(target_bitrate, lossRate, rtt, | 129 return sender_.SetChannelParameters(target_bitrate, lossRate, rtt); |
149 rate_allocator_.get()); | |
150 } | 130 } |
151 | 131 |
152 int32_t RegisterProtectionCallback( | 132 int32_t RegisterProtectionCallback( |
153 VCMProtectionCallback* protection) override { | 133 VCMProtectionCallback* protection) override { |
154 return sender_.RegisterProtectionCallback(protection); | 134 return sender_.RegisterProtectionCallback(protection); |
155 } | 135 } |
156 | 136 |
157 int32_t SetVideoProtection(VCMVideoProtection videoProtection, | 137 int32_t SetVideoProtection(VCMVideoProtection videoProtection, |
158 bool enable) override { | 138 bool enable) override { |
159 // TODO(pbos): Remove enable from receive-side protection modes as well. | 139 // TODO(pbos): Remove enable from receive-side protection modes as well. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 void RegisterPostEncodeImageCallback( | 249 void RegisterPostEncodeImageCallback( |
270 EncodedImageCallback* observer) override { | 250 EncodedImageCallback* observer) override { |
271 post_encode_callback_.Register(observer); | 251 post_encode_callback_.Register(observer); |
272 } | 252 } |
273 | 253 |
274 void TriggerDecoderShutdown() override { receiver_.TriggerDecoderShutdown(); } | 254 void TriggerDecoderShutdown() override { receiver_.TriggerDecoderShutdown(); } |
275 | 255 |
276 private: | 256 private: |
277 EncodedImageCallbackWrapper post_encode_callback_; | 257 EncodedImageCallbackWrapper post_encode_callback_; |
278 vcm::VideoSender sender_; | 258 vcm::VideoSender sender_; |
279 std::unique_ptr<VideoBitrateAllocator> rate_allocator_; | |
280 vcm::VideoReceiver receiver_; | 259 vcm::VideoReceiver receiver_; |
281 }; | 260 }; |
282 } // namespace | 261 } // namespace |
283 | 262 |
284 void VideoCodingModule::Codec(VideoCodecType codecType, VideoCodec* codec) { | 263 void VideoCodingModule::Codec(VideoCodecType codecType, VideoCodec* codec) { |
285 VCMCodecDataBase::Codec(codecType, codec); | 264 VCMCodecDataBase::Codec(codecType, codec); |
286 } | 265 } |
287 | 266 |
288 // Create method for the new jitter buffer. | 267 // Create method for the new jitter buffer. |
289 VideoCodingModule* VideoCodingModule::Create( | 268 VideoCodingModule* VideoCodingModule::Create( |
(...skipping 22 matching lines...) Expand all Loading... |
312 EventFactory* event_factory, | 291 EventFactory* event_factory, |
313 NackSender* nack_sender, | 292 NackSender* nack_sender, |
314 KeyFrameRequestSender* keyframe_request_sender) { | 293 KeyFrameRequestSender* keyframe_request_sender) { |
315 assert(clock); | 294 assert(clock); |
316 assert(event_factory); | 295 assert(event_factory); |
317 return new VideoCodingModuleImpl(clock, event_factory, nack_sender, | 296 return new VideoCodingModuleImpl(clock, event_factory, nack_sender, |
318 keyframe_request_sender, nullptr); | 297 keyframe_request_sender, nullptr); |
319 } | 298 } |
320 | 299 |
321 } // namespace webrtc | 300 } // namespace webrtc |
OLD | NEW |