Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: webrtc/modules/video_coding/test/vcm_payload_sink_factory.cc

Issue 1721353002: Replace scoped_ptr with unique_ptr in webrtc/modules/video_coding/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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/test/vcm_payload_sink_factory.h" 11 #include "webrtc/modules/video_coding/test/vcm_payload_sink_factory.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 14
15 #include <algorithm> 15 #include <algorithm>
16 16
17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
18 #include "webrtc/modules/video_coding/test/test_util.h" 18 #include "webrtc/modules/video_coding/test/test_util.h"
19 #include "webrtc/system_wrappers/include/clock.h" 19 #include "webrtc/system_wrappers/include/clock.h"
20 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 20 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
21 21
22 namespace webrtc { 22 namespace webrtc {
23 namespace rtpplayer { 23 namespace rtpplayer {
24 24
25 class VcmPayloadSinkFactory::VcmPayloadSink : public PayloadSinkInterface, 25 class VcmPayloadSinkFactory::VcmPayloadSink : public PayloadSinkInterface,
26 public VCMPacketRequestCallback { 26 public VCMPacketRequestCallback {
27 public: 27 public:
28 VcmPayloadSink(VcmPayloadSinkFactory* factory, 28 VcmPayloadSink(VcmPayloadSinkFactory* factory,
29 RtpStreamInterface* stream, 29 RtpStreamInterface* stream,
30 rtc::scoped_ptr<VideoCodingModule>* vcm, 30 std::unique_ptr<VideoCodingModule>* vcm,
31 rtc::scoped_ptr<FileOutputFrameReceiver>* frame_receiver) 31 std::unique_ptr<FileOutputFrameReceiver>* frame_receiver)
32 : factory_(factory), stream_(stream), vcm_(), frame_receiver_() { 32 : factory_(factory), stream_(stream), vcm_(), frame_receiver_() {
33 assert(factory); 33 assert(factory);
34 assert(stream); 34 assert(stream);
35 assert(vcm); 35 assert(vcm);
36 assert(vcm->get()); 36 assert(vcm->get());
37 assert(frame_receiver); 37 assert(frame_receiver);
38 assert(frame_receiver->get()); 38 assert(frame_receiver->get());
39 vcm_.swap(*vcm); 39 vcm_.swap(*vcm);
40 frame_receiver_.swap(*frame_receiver); 40 frame_receiver_.swap(*frame_receiver);
41 vcm_->RegisterPacketRequestCallback(this); 41 vcm_->RegisterPacketRequestCallback(this);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 83
84 bool Decode() { 84 bool Decode() {
85 vcm_->Decode(10000); 85 vcm_->Decode(10000);
86 return true; 86 return true;
87 } 87 }
88 88
89 private: 89 private:
90 VcmPayloadSinkFactory* factory_; 90 VcmPayloadSinkFactory* factory_;
91 RtpStreamInterface* stream_; 91 RtpStreamInterface* stream_;
92 rtc::scoped_ptr<VideoCodingModule> vcm_; 92 std::unique_ptr<VideoCodingModule> vcm_;
93 rtc::scoped_ptr<FileOutputFrameReceiver> frame_receiver_; 93 std::unique_ptr<FileOutputFrameReceiver> frame_receiver_;
94 94
95 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(VcmPayloadSink); 95 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(VcmPayloadSink);
96 }; 96 };
97 97
98 VcmPayloadSinkFactory::VcmPayloadSinkFactory( 98 VcmPayloadSinkFactory::VcmPayloadSinkFactory(
99 const std::string& base_out_filename, 99 const std::string& base_out_filename,
100 Clock* clock, 100 Clock* clock,
101 bool protection_enabled, 101 bool protection_enabled,
102 VCMVideoProtection protection_method, 102 VCMVideoProtection protection_method,
103 int64_t rtt_ms, 103 int64_t rtt_ms,
(...skipping 15 matching lines...) Expand all
119 119
120 VcmPayloadSinkFactory::~VcmPayloadSinkFactory() { 120 VcmPayloadSinkFactory::~VcmPayloadSinkFactory() {
121 assert(sinks_.empty()); 121 assert(sinks_.empty());
122 } 122 }
123 123
124 PayloadSinkInterface* VcmPayloadSinkFactory::Create( 124 PayloadSinkInterface* VcmPayloadSinkFactory::Create(
125 RtpStreamInterface* stream) { 125 RtpStreamInterface* stream) {
126 assert(stream); 126 assert(stream);
127 CriticalSectionScoped cs(crit_sect_.get()); 127 CriticalSectionScoped cs(crit_sect_.get());
128 128
129 rtc::scoped_ptr<VideoCodingModule> vcm( 129 std::unique_ptr<VideoCodingModule> vcm(
130 VideoCodingModule::Create(clock_, null_event_factory_.get())); 130 VideoCodingModule::Create(clock_, null_event_factory_.get()));
131 if (vcm.get() == NULL) { 131 if (vcm.get() == NULL) {
132 return NULL; 132 return NULL;
133 } 133 }
134 134
135 const PayloadTypes& plt = stream->payload_types(); 135 const PayloadTypes& plt = stream->payload_types();
136 for (PayloadTypesIterator it = plt.begin(); it != plt.end(); ++it) { 136 for (PayloadTypesIterator it = plt.begin(); it != plt.end(); ++it) {
137 if (it->codec_type() != kVideoCodecULPFEC && 137 if (it->codec_type() != kVideoCodecULPFEC &&
138 it->codec_type() != kVideoCodecRED) { 138 it->codec_type() != kVideoCodecRED) {
139 VideoCodec codec; 139 VideoCodec codec;
140 VideoCodingModule::Codec(it->codec_type(), &codec); 140 VideoCodingModule::Codec(it->codec_type(), &codec);
141 codec.plType = it->payload_type(); 141 codec.plType = it->payload_type();
142 if (vcm->RegisterReceiveCodec(&codec, 1) < 0) { 142 if (vcm->RegisterReceiveCodec(&codec, 1) < 0) {
143 return NULL; 143 return NULL;
144 } 144 }
145 } 145 }
146 } 146 }
147 147
148 vcm->SetChannelParameters(0, 0, rtt_ms_); 148 vcm->SetChannelParameters(0, 0, rtt_ms_);
149 vcm->SetVideoProtection(protection_method_, protection_enabled_); 149 vcm->SetVideoProtection(protection_method_, protection_enabled_);
150 vcm->SetRenderDelay(render_delay_ms_); 150 vcm->SetRenderDelay(render_delay_ms_);
151 vcm->SetMinimumPlayoutDelay(min_playout_delay_ms_); 151 vcm->SetMinimumPlayoutDelay(min_playout_delay_ms_);
152 vcm->SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, 0); 152 vcm->SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, 0);
153 153
154 rtc::scoped_ptr<FileOutputFrameReceiver> frame_receiver( 154 std::unique_ptr<FileOutputFrameReceiver> frame_receiver(
155 new FileOutputFrameReceiver(base_out_filename_, stream->ssrc())); 155 new FileOutputFrameReceiver(base_out_filename_, stream->ssrc()));
156 rtc::scoped_ptr<VcmPayloadSink> sink( 156 std::unique_ptr<VcmPayloadSink> sink(
157 new VcmPayloadSink(this, stream, &vcm, &frame_receiver)); 157 new VcmPayloadSink(this, stream, &vcm, &frame_receiver));
158 158
159 sinks_.push_back(sink.get()); 159 sinks_.push_back(sink.get());
160 return sink.release(); 160 return sink.release();
161 } 161 }
162 162
163 int VcmPayloadSinkFactory::DecodeAndProcessAll(bool decode_dual_frame) { 163 int VcmPayloadSinkFactory::DecodeAndProcessAll(bool decode_dual_frame) {
164 CriticalSectionScoped cs(crit_sect_.get()); 164 CriticalSectionScoped cs(crit_sect_.get());
165 assert(clock_); 165 assert(clock_);
166 bool should_decode = (clock_->TimeInMilliseconds() % 5) == 0; 166 bool should_decode = (clock_->TimeInMilliseconds() % 5) == 0;
(...skipping 28 matching lines...) Expand all
195 void VcmPayloadSinkFactory::Remove(VcmPayloadSink* sink) { 195 void VcmPayloadSinkFactory::Remove(VcmPayloadSink* sink) {
196 assert(sink); 196 assert(sink);
197 CriticalSectionScoped cs(crit_sect_.get()); 197 CriticalSectionScoped cs(crit_sect_.get());
198 Sinks::iterator it = std::find(sinks_.begin(), sinks_.end(), sink); 198 Sinks::iterator it = std::find(sinks_.begin(), sinks_.end(), sink);
199 assert(it != sinks_.end()); 199 assert(it != sinks_.end());
200 sinks_.erase(it); 200 sinks_.erase(it);
201 } 201 }
202 202
203 } // namespace rtpplayer 203 } // namespace rtpplayer
204 } // namespace webrtc 204 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/test/vcm_payload_sink_factory.h ('k') | webrtc/modules/video_coding/test/video_rtp_play.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698