14d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org/*
24d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
34d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org *
44d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org *  Use of this source code is governed by a BSD-style license
54d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org *  that can be found in the LICENSE file in the root of the source
64d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org *  tree. An additional intellectual property rights grant can be found
74d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org *  in the file PATENTS.  All contributing project authors may
84d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
94d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org */
104d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
114d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org#include "webrtc/modules/video_coding/main/test/vcm_payload_sink_factory.h"
124d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
133f45c2e0ac4cb280f941efa3a3476895795e3dd6pbos@webrtc.org#include <assert.h>
143f45c2e0ac4cb280f941efa3a3476895795e3dd6pbos@webrtc.org
154d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org#include <algorithm>
164d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
174d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
184d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org#include "webrtc/modules/video_coding/main/test/test_util.h"
194d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org#include "webrtc/system_wrappers/interface/clock.h"
204d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
214d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
224d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.orgnamespace webrtc {
234d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.orgnamespace rtpplayer {
244d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
254d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.orgclass VcmPayloadSinkFactory::VcmPayloadSink
264d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    : public PayloadSinkInterface,
2731a8ce783a62afe0c014bc23f0be8c2a779dbd74mikhal@webrtc.org      public VCMPacketRequestCallback {
284d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org public:
294d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  VcmPayloadSink(VcmPayloadSinkFactory* factory,
304d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org                 RtpStreamInterface* stream,
314d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org                 scoped_ptr<VideoCodingModule>* vcm,
324d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org                 scoped_ptr<FileOutputFrameReceiver>* frame_receiver)
334d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      : factory_(factory),
344d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org        stream_(stream),
354d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org        vcm_(),
364d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org        frame_receiver_() {
374d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    assert(factory);
384d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    assert(stream);
394d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    assert(vcm);
404d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    assert(vcm->get());
414d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    assert(frame_receiver);
424d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    assert(frame_receiver->get());
434d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    vcm_.swap(*vcm);
444d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    frame_receiver_.swap(*frame_receiver);
454d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    vcm_->RegisterPacketRequestCallback(this);
46f2982c95ac0640dd99c2770e9fa1171b4cefad57mikhal@webrtc.org    vcm_->RegisterReceiveCallback(frame_receiver_.get());
474d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  }
484d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
494d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  virtual ~VcmPayloadSink() {
504d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    factory_->Remove(this);
514d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  }
524d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
534d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  // PayloadSinkInterface
5452b2ee5489898b667e38dbee2d40202597f1fc0cpbos@webrtc.org  virtual int32_t OnReceivedPayloadData(
5552b2ee5489898b667e38dbee2d40202597f1fc0cpbos@webrtc.org      const uint8_t* payload_data,
5652b2ee5489898b667e38dbee2d40202597f1fc0cpbos@webrtc.org      const uint16_t payload_size,
576dc729b3239305d0f8edd2ecf6bef2e2f6bd661astefan@webrtc.org      const WebRtcRTPHeader* rtp_header) OVERRIDE {
584d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    return vcm_->IncomingPacket(payload_data, payload_size, *rtp_header);
594d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  }
604d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
617fc75bbb65cc1cd99fdf45d9fce44bcce1396dfawu@webrtc.org  virtual bool OnRecoveredPacket(const uint8_t* packet,
626dc729b3239305d0f8edd2ecf6bef2e2f6bd661astefan@webrtc.org                                 int packet_length) OVERRIDE {
637fc75bbb65cc1cd99fdf45d9fce44bcce1396dfawu@webrtc.org    // We currently don't handle FEC.
647fc75bbb65cc1cd99fdf45d9fce44bcce1396dfawu@webrtc.org    return true;
657fc75bbb65cc1cd99fdf45d9fce44bcce1396dfawu@webrtc.org  }
667fc75bbb65cc1cd99fdf45d9fce44bcce1396dfawu@webrtc.org
674d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  // VCMPacketRequestCallback
6852b2ee5489898b667e38dbee2d40202597f1fc0cpbos@webrtc.org  virtual int32_t ResendPackets(const uint16_t* sequence_numbers,
696dc729b3239305d0f8edd2ecf6bef2e2f6bd661astefan@webrtc.org                                uint16_t length) OVERRIDE {
704d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    stream_->ResendPackets(sequence_numbers, length);
714d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    return 0;
724d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  }
734d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
744d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  int DecodeAndProcess(bool should_decode, bool decode_dual_frame) {
754d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    if (should_decode) {
764d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      if (vcm_->Decode() < 0) {
774d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org        return -1;
784d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      }
794d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    }
804d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    while (decode_dual_frame && vcm_->DecodeDualFrame(0) == 1) {
814d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    }
824d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    return Process() ? 0 : -1;
834d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  }
844d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
854d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  bool Process() {
864d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    if (vcm_->TimeUntilNextProcess() <= 0) {
874d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      if (vcm_->Process() < 0) {
884d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org        return false;
894d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      }
904d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    }
914d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    return true;
924d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  }
934d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
944d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  bool Decode() {
954d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    vcm_->Decode(10000);
964d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    while (vcm_->DecodeDualFrame(0) == 1) {
974d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    }
984d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    return true;
994d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  }
1004d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
1014d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org private:
1024d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  VcmPayloadSinkFactory* factory_;
1034d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  RtpStreamInterface* stream_;
1044d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  scoped_ptr<VideoCodingModule> vcm_;
1054d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  scoped_ptr<FileOutputFrameReceiver> frame_receiver_;
1064d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
1074d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  DISALLOW_IMPLICIT_CONSTRUCTORS(VcmPayloadSink);
1084d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org};
1094d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
1104d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.orgVcmPayloadSinkFactory::VcmPayloadSinkFactory(
1118edcccef11eabb0dd98a061c9d640b2b7743609estefan@webrtc.org    const std::string& base_out_filename,
1128edcccef11eabb0dd98a061c9d640b2b7743609estefan@webrtc.org    Clock* clock,
1138edcccef11eabb0dd98a061c9d640b2b7743609estefan@webrtc.org    bool protection_enabled,
1148edcccef11eabb0dd98a061c9d640b2b7743609estefan@webrtc.org    VCMVideoProtection protection_method,
1158edcccef11eabb0dd98a061c9d640b2b7743609estefan@webrtc.org    uint32_t rtt_ms,
1168edcccef11eabb0dd98a061c9d640b2b7743609estefan@webrtc.org    uint32_t render_delay_ms,
1178edcccef11eabb0dd98a061c9d640b2b7743609estefan@webrtc.org    uint32_t min_playout_delay_ms)
1184d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    : base_out_filename_(base_out_filename),
1194d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      clock_(clock),
1204d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      protection_enabled_(protection_enabled),
1214d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      protection_method_(protection_method),
1224d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      rtt_ms_(rtt_ms),
1234d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      render_delay_ms_(render_delay_ms),
1244d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      min_playout_delay_ms_(min_playout_delay_ms),
1254d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      null_event_factory_(new NullEventFactory()),
1264d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
1278edcccef11eabb0dd98a061c9d640b2b7743609estefan@webrtc.org      sinks_() {
1284d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  assert(clock);
1294d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  assert(crit_sect_.get());
1304d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org}
1314d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
1324d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.orgVcmPayloadSinkFactory::~VcmPayloadSinkFactory() {
1334d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  assert(sinks_.empty());
1344d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org}
1354d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
1364d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.orgPayloadSinkInterface* VcmPayloadSinkFactory::Create(
1374d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    RtpStreamInterface* stream) {
1384d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  assert(stream);
1394d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  CriticalSectionScoped cs(crit_sect_.get());
1404d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
1414d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  scoped_ptr<VideoCodingModule> vcm(
1428edcccef11eabb0dd98a061c9d640b2b7743609estefan@webrtc.org      VideoCodingModule::Create(clock_, null_event_factory_.get()));
1434d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  if (vcm.get() == NULL) {
1444d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    return NULL;
1454d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  }
1464d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  if (vcm->InitializeReceiver() < 0) {
1474d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    return NULL;
1484d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  }
1494d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
1504d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  const PayloadTypes& plt = stream->payload_types();
1514d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  for (PayloadTypesIterator it = plt.begin(); it != plt.end();
1524d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      ++it) {
1534d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    if (it->codec_type() != kVideoCodecULPFEC &&
1544d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org        it->codec_type() != kVideoCodecRED) {
1554d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      VideoCodec codec;
1564d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      if (VideoCodingModule::Codec(it->codec_type(), &codec) < 0) {
1574d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org        return NULL;
1584d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      }
1594d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      codec.plType = it->payload_type();
1604d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      if (vcm->RegisterReceiveCodec(&codec, 1) < 0) {
1614d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org        return NULL;
1624d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      }
1634d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    }
1644d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  }
1654d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
1664d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  vcm->SetChannelParameters(0, 0, rtt_ms_);
1674d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  vcm->SetVideoProtection(protection_method_, protection_enabled_);
1684d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  vcm->SetRenderDelay(render_delay_ms_);
1694d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  vcm->SetMinimumPlayoutDelay(min_playout_delay_ms_);
17006ad384100b8b493e4a3f37877caac520189fec3stefan@webrtc.org  vcm->SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, 0);
1714d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
1724d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  scoped_ptr<FileOutputFrameReceiver> frame_receiver(
1734d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      new FileOutputFrameReceiver(base_out_filename_, stream->ssrc()));
1744d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  scoped_ptr<VcmPayloadSink> sink(
175f2982c95ac0640dd99c2770e9fa1171b4cefad57mikhal@webrtc.org      new VcmPayloadSink(this, stream, &vcm, &frame_receiver));
1764d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
1774d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  sinks_.push_back(sink.get());
1784d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  return sink.release();
1794d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org}
1804d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
1814d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.orgint VcmPayloadSinkFactory::DecodeAndProcessAll(bool decode_dual_frame) {
1824d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  CriticalSectionScoped cs(crit_sect_.get());
1834d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  assert(clock_);
1844d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  bool should_decode = (clock_->TimeInMilliseconds() % 5) == 0;
1854d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  for (Sinks::iterator it = sinks_.begin(); it != sinks_.end(); ++it) {
1864d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    if ((*it)->DecodeAndProcess(should_decode, decode_dual_frame) < 0) {
1874d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      return -1;
1884d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    }
1894d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  }
1904d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  return 0;
1914d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org}
1924d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
1934d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.orgbool VcmPayloadSinkFactory::ProcessAll() {
1944d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  CriticalSectionScoped cs(crit_sect_.get());
1954d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  for (Sinks::iterator it = sinks_.begin(); it != sinks_.end(); ++it) {
1964d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    if (!(*it)->Process()) {
1974d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      return false;
1984d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    }
1994d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  }
2004d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  return true;
2014d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org}
2024d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
2034d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.orgbool VcmPayloadSinkFactory::DecodeAll() {
2044d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  CriticalSectionScoped cs(crit_sect_.get());
2054d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  for (Sinks::iterator it = sinks_.begin(); it != sinks_.end(); ++it) {
2064d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    if (!(*it)->Decode()) {
2074d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org      return false;
2084d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org    }
2094d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  }
2104d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  return true;
2114d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org}
2124d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
2134d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.orgvoid VcmPayloadSinkFactory::Remove(VcmPayloadSink* sink) {
2144d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  assert(sink);
2154d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  CriticalSectionScoped cs(crit_sect_.get());
2164d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  Sinks::iterator it = std::find(sinks_.begin(), sinks_.end(), sink);
2174d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  assert(it != sinks_.end());
2184d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org  sinks_.erase(it);
2194d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org}
2204d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org
2214d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org}  // namespace rtpplayer
2224d2a2eccaef42c24ada13e98fe2917439d882033solenberg@webrtc.org}  // namespace webrtc
223