OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2016 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 #include "webrtc/modules/video_coding/include/video_bitrate_allocator_factory.h" | |
12 | |
13 #include "webrtc/base/basictypes.h" | |
14 #include "webrtc/common_video/include/video_bitrate_allocator.h" | |
15 #include "webrtc/common_types.h" | |
16 #include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h" | |
17 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" | |
18 #include "webrtc/modules/video_coding/utility/simulcast_rate_allocator.h" | |
19 #include "webrtc/modules/video_coding/utility/default_video_bitrate_allocator.h" | |
20 #include "webrtc/system_wrappers/include/clock.h" | |
21 | |
22 namespace webrtc { | |
23 | |
24 struct ScreenshareTemporalLayersFactory : webrtc::TemporalLayersFactory { | |
25 ScreenshareTemporalLayersFactory() {} | |
26 virtual ~ScreenshareTemporalLayersFactory() {} | |
27 | |
28 virtual webrtc::TemporalLayers* Create(int simulcast_id, | |
29 int num_temporal_layers, | |
30 uint8_t initial_tl0_pic_idx) const { | |
31 webrtc::TemporalLayers* tl = new webrtc::ScreenshareLayers( | |
32 num_temporal_layers, rand(), webrtc::Clock::GetRealTimeClock()); | |
33 if (listener_) | |
34 listener_->OnTemporalLayersCreated(simulcast_id, tl); | |
35 return tl; | |
36 } | |
37 }; | |
38 | |
39 std::unique_ptr<VideoBitrateAllocator> | |
40 VideoBitrateAllocatorFactory::GetBitrateAllocator(VideoCodec* codec) { | |
perkj_webrtc
2016/10/27 12:57:31
it feels weird that GetBitrateAllocator take a non
sprang_webrtc
2016/11/01 18:03:16
I don't think it makes sense to have the rate allo
| |
41 std::unique_ptr<VideoBitrateAllocator> rate_allocator; | |
42 | |
43 switch (codec->codecType) { | |
44 case kVideoCodecVP8: { | |
45 // Set up default VP8 temporal layer factory, if not provided. | |
46 std::unique_ptr<TemporalLayersFactory> tl_factory; | |
47 if (!codec->codecSpecific.VP8.tl_factory) { | |
48 if (codec->mode == kScreensharing && | |
49 codec->numberOfSimulcastStreams == 1 && | |
50 codec->codecSpecific.VP8.numberOfTemporalLayers == 2) { | |
51 // Conference mode temporal layering for screen content. | |
52 tl_factory.reset(new ScreenshareTemporalLayersFactory()); | |
53 } else { | |
54 // Standard video temporal layers. | |
55 tl_factory.reset(new TemporalLayersFactory()); | |
56 } | |
57 codec->codecSpecific.VP8.tl_factory = tl_factory.get(); | |
58 } | |
59 rate_allocator.reset( | |
60 new SimulcastRateAllocator(*codec, std::move(tl_factory))); | |
61 codec->codecSpecific.VP8.tl_factory->SetListener( | |
62 static_cast<SimulcastRateAllocator*>(rate_allocator.get())); | |
63 } break; | |
64 default: | |
65 rate_allocator.reset(new DefaultVideoBitrateAllocator(*codec)); | |
66 } | |
67 | |
68 return rate_allocator; | |
69 } | |
70 | |
71 } // namespace webrtc | |
OLD | NEW |