| OLD | NEW | 
|    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 |   25 class VcmPayloadSinkFactory::VcmPayloadSink : public PayloadSinkInterface, | 
|   26     : public PayloadSinkInterface, |   26                                               public VCMPacketRequestCallback { | 
|   27       public VCMPacketRequestCallback { |  | 
|   28  public: |   27  public: | 
|   29   VcmPayloadSink(VcmPayloadSinkFactory* factory, |   28   VcmPayloadSink(VcmPayloadSinkFactory* factory, | 
|   30                  RtpStreamInterface* stream, |   29                  RtpStreamInterface* stream, | 
|   31                  rtc::scoped_ptr<VideoCodingModule>* vcm, |   30                  rtc::scoped_ptr<VideoCodingModule>* vcm, | 
|   32                  rtc::scoped_ptr<FileOutputFrameReceiver>* frame_receiver) |   31                  rtc::scoped_ptr<FileOutputFrameReceiver>* frame_receiver) | 
|   33       : factory_(factory), stream_(stream), vcm_(), frame_receiver_() { |   32       : factory_(factory), stream_(stream), vcm_(), frame_receiver_() { | 
|   34     assert(factory); |   33     assert(factory); | 
|   35     assert(stream); |   34     assert(stream); | 
|   36     assert(vcm); |   35     assert(vcm); | 
|   37     assert(vcm->get()); |   36     assert(vcm->get()); | 
|   38     assert(frame_receiver); |   37     assert(frame_receiver); | 
|   39     assert(frame_receiver->get()); |   38     assert(frame_receiver->get()); | 
|   40     vcm_.swap(*vcm); |   39     vcm_.swap(*vcm); | 
|   41     frame_receiver_.swap(*frame_receiver); |   40     frame_receiver_.swap(*frame_receiver); | 
|   42     vcm_->RegisterPacketRequestCallback(this); |   41     vcm_->RegisterPacketRequestCallback(this); | 
|   43     vcm_->RegisterReceiveCallback(frame_receiver_.get()); |   42     vcm_->RegisterReceiveCallback(frame_receiver_.get()); | 
|   44   } |   43   } | 
|   45  |   44  | 
|   46   virtual ~VcmPayloadSink() { |   45   virtual ~VcmPayloadSink() { factory_->Remove(this); } | 
|   47     factory_->Remove(this); |  | 
|   48   } |  | 
|   49  |   46  | 
|   50   // PayloadSinkInterface |   47   // PayloadSinkInterface | 
|   51   int32_t OnReceivedPayloadData(const uint8_t* payload_data, |   48   int32_t OnReceivedPayloadData(const uint8_t* payload_data, | 
|   52                                 const size_t payload_size, |   49                                 const size_t payload_size, | 
|   53                                 const WebRtcRTPHeader* rtp_header) override { |   50                                 const WebRtcRTPHeader* rtp_header) override { | 
|   54     return vcm_->IncomingPacket(payload_data, payload_size, *rtp_header); |   51     return vcm_->IncomingPacket(payload_data, payload_size, *rtp_header); | 
|   55   } |   52   } | 
|   56  |   53  | 
|   57   bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override { |   54   bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override { | 
|   58     // We currently don't handle FEC. |   55     // We currently don't handle FEC. | 
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  129   assert(stream); |  126   assert(stream); | 
|  130   CriticalSectionScoped cs(crit_sect_.get()); |  127   CriticalSectionScoped cs(crit_sect_.get()); | 
|  131  |  128  | 
|  132   rtc::scoped_ptr<VideoCodingModule> vcm( |  129   rtc::scoped_ptr<VideoCodingModule> vcm( | 
|  133       VideoCodingModule::Create(clock_, null_event_factory_.get())); |  130       VideoCodingModule::Create(clock_, null_event_factory_.get())); | 
|  134   if (vcm.get() == NULL) { |  131   if (vcm.get() == NULL) { | 
|  135     return NULL; |  132     return NULL; | 
|  136   } |  133   } | 
|  137  |  134  | 
|  138   const PayloadTypes& plt = stream->payload_types(); |  135   const PayloadTypes& plt = stream->payload_types(); | 
|  139   for (PayloadTypesIterator it = plt.begin(); it != plt.end(); |  136   for (PayloadTypesIterator it = plt.begin(); it != plt.end(); ++it) { | 
|  140       ++it) { |  | 
|  141     if (it->codec_type() != kVideoCodecULPFEC && |  137     if (it->codec_type() != kVideoCodecULPFEC && | 
|  142         it->codec_type() != kVideoCodecRED) { |  138         it->codec_type() != kVideoCodecRED) { | 
|  143       VideoCodec codec; |  139       VideoCodec codec; | 
|  144       if (VideoCodingModule::Codec(it->codec_type(), &codec) < 0) { |  140       if (VideoCodingModule::Codec(it->codec_type(), &codec) < 0) { | 
|  145         return NULL; |  141         return NULL; | 
|  146       } |  142       } | 
|  147       codec.plType = it->payload_type(); |  143       codec.plType = it->payload_type(); | 
|  148       if (vcm->RegisterReceiveCodec(&codec, 1) < 0) { |  144       if (vcm->RegisterReceiveCodec(&codec, 1) < 0) { | 
|  149         return NULL; |  145         return NULL; | 
|  150       } |  146       } | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  201 void VcmPayloadSinkFactory::Remove(VcmPayloadSink* sink) { |  197 void VcmPayloadSinkFactory::Remove(VcmPayloadSink* sink) { | 
|  202   assert(sink); |  198   assert(sink); | 
|  203   CriticalSectionScoped cs(crit_sect_.get()); |  199   CriticalSectionScoped cs(crit_sect_.get()); | 
|  204   Sinks::iterator it = std::find(sinks_.begin(), sinks_.end(), sink); |  200   Sinks::iterator it = std::find(sinks_.begin(), sinks_.end(), sink); | 
|  205   assert(it != sinks_.end()); |  201   assert(it != sinks_.end()); | 
|  206   sinks_.erase(it); |  202   sinks_.erase(it); | 
|  207 } |  203 } | 
|  208  |  204  | 
|  209 }  // namespace rtpplayer |  205 }  // namespace rtpplayer | 
|  210 }  // namespace webrtc |  206 }  // namespace webrtc | 
| OLD | NEW |