fakewebrtcvideoengine.h revision b884eb611803b4720e55bdd8b51602edf7061061
128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org/*
228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * libjingle
328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * Copyright 2010 Google Inc.
428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *
528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * Redistribution and use in source and binary forms, with or without
628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * modification, are permitted provided that the following conditions are met:
728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *
828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *  1. Redistributions of source code must retain the above copyright notice,
928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *     this list of conditions and the following disclaimer.
1028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *  2. Redistributions in binary form must reproduce the above copyright notice,
1128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *     this list of conditions and the following disclaimer in the documentation
1228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *     and/or other materials provided with the distribution.
1328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *  3. The name of the author may not be used to endorse or promote products
1428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *     derived from this software without specific prior written permission.
1528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org *
1628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
1728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
1928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org */
2728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
2828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#ifndef TALK_MEDIA_WEBRTC_FAKEWEBRTCVIDEOENGINE_H_
2928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#define TALK_MEDIA_WEBRTC_FAKEWEBRTCVIDEOENGINE_H_
3028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
3128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#include <map>
3228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#include <set>
3328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#include <vector>
3428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
3528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#include "talk/base/basictypes.h"
369caf2765b285f7511d8355177c2d55209d7573e4wu@webrtc.org#include "talk/base/gunit.h"
3728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#include "talk/base/stringutils.h"
3828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#include "talk/media/base/codec.h"
3928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#include "talk/media/webrtc/fakewebrtccommon.h"
4028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#include "talk/media/webrtc/webrtcvideodecoderfactory.h"
4128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#include "talk/media/webrtc/webrtcvideoencoderfactory.h"
4228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#include "talk/media/webrtc/webrtcvie.h"
4328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
441e6cb2c5d21d778437e650170de397ace4b39b08wu@webrtc.org#if !defined(USE_WEBRTC_DEV_BRANCH)
4528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgnamespace webrtc {
4628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
4728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgbool operator==(const webrtc::VideoCodec& c1, const webrtc::VideoCodec& c2) {
4828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  return memcmp(&c1, &c2, sizeof(c1)) == 0;
4928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org}
5028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
5128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org}
521e6cb2c5d21d778437e650170de397ace4b39b08wu@webrtc.org#endif
5328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
5428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgnamespace cricket {
5528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
5628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#define WEBRTC_CHECK_CAPTURER(capturer) \
5728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  if (capturers_.find(capturer) == capturers_.end()) return -1;
5828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
5928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#define WEBRTC_ASSERT_CAPTURER(capturer) \
6028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  ASSERT(capturers_.find(capturer) != capturers_.end());
6128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
6228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgstatic const int kMinVideoBitrate = 100;
6328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgstatic const int kStartVideoBitrate = 300;
6428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgstatic const int kMaxVideoBitrate = 1000;
6528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
6628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org// WebRtc channel id and capture id share the same number space.
6728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org// This is how AddRenderer(renderId, ...) is able to tell if it is adding a
6828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org// renderer for a channel or it is adding a renderer for a capturer.
6928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgstatic const int kViEChannelIdBase = 0;
7028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgstatic const int kViEChannelIdMax = 1000;
7128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgstatic const int kViECaptureIdBase = 10000;  // Make sure there is a gap.
7228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgstatic const int kViECaptureIdMax = 11000;
7328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
7428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org// Fake class for mocking out webrtc::VideoDecoder
7528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgclass FakeWebRtcVideoDecoder : public webrtc::VideoDecoder {
7628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org public:
7728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  FakeWebRtcVideoDecoder()
7828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      : num_frames_received_(0) {
7928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
8028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
8128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual int32 InitDecode(const webrtc::VideoCodec*, int32) {
8228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return WEBRTC_VIDEO_CODEC_OK;
8328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
8428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
8528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual int32 Decode(
8628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      const webrtc::EncodedImage&, bool, const webrtc::RTPFragmentationHeader*,
8728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      const webrtc::CodecSpecificInfo*, int64) {
8828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    num_frames_received_++;
8928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return WEBRTC_VIDEO_CODEC_OK;
9028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
9128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
9228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual int32 RegisterDecodeCompleteCallback(
9328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      webrtc::DecodedImageCallback*) {
9428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return WEBRTC_VIDEO_CODEC_OK;
9528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
9628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
9728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual int32 Release() {
9828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return WEBRTC_VIDEO_CODEC_OK;
9928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
10028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
10128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual int32 Reset() {
10228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return WEBRTC_VIDEO_CODEC_OK;
10328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
10428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
10528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetNumFramesReceived() const {
10628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return num_frames_received_;
10728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
10828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
10928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org private:
11028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int num_frames_received_;
11128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org};
11228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
11328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org// Fake class for mocking out WebRtcVideoDecoderFactory.
11428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgclass FakeWebRtcVideoDecoderFactory : public WebRtcVideoDecoderFactory {
11528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org public:
11628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  FakeWebRtcVideoDecoderFactory()
11728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      : num_created_decoders_(0) {
11828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
11928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
12028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual webrtc::VideoDecoder* CreateVideoDecoder(
12128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      webrtc::VideoCodecType type) {
12228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (supported_codec_types_.count(type) == 0) {
12328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return NULL;
12428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
12528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    FakeWebRtcVideoDecoder* decoder = new FakeWebRtcVideoDecoder();
12628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    decoders_.push_back(decoder);
12728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    num_created_decoders_++;
12828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return decoder;
12928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
13028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
13128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual void DestroyVideoDecoder(webrtc::VideoDecoder* decoder) {
13228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    decoders_.erase(
13328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        std::remove(decoders_.begin(), decoders_.end(), decoder),
13428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        decoders_.end());
13528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    delete decoder;
13628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
13728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
13828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  void AddSupportedVideoCodecType(webrtc::VideoCodecType type) {
13928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    supported_codec_types_.insert(type);
14028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
14128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
14228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetNumCreatedDecoders() {
14328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return num_created_decoders_;
14428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
14528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
14628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  const std::vector<FakeWebRtcVideoDecoder*>& decoders() {
14728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return decoders_;
14828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
14928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
15028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org private:
15128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  std::set<webrtc::VideoCodecType> supported_codec_types_;
15228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  std::vector<FakeWebRtcVideoDecoder*> decoders_;
15328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int num_created_decoders_;
15428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org};
15528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
15628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org// Fake class for mocking out webrtc::VideoEnoder
15728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgclass FakeWebRtcVideoEncoder : public webrtc::VideoEncoder {
15828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org public:
15928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  FakeWebRtcVideoEncoder() {}
16028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
16128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual int32 InitEncode(const webrtc::VideoCodec* codecSettings,
16228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                           int32 numberOfCores,
16328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                           uint32 maxPayloadSize) {
16428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return WEBRTC_VIDEO_CODEC_OK;
16528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
16628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
16728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual int32 Encode(
16828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      const webrtc::I420VideoFrame& inputImage,
16928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org            const webrtc::CodecSpecificInfo* codecSpecificInfo,
17028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org            const std::vector<webrtc::VideoFrameType>* frame_types) {
17128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return WEBRTC_VIDEO_CODEC_OK;
17228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
17328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
17428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual int32 RegisterEncodeCompleteCallback(
17528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      webrtc::EncodedImageCallback* callback) {
17628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return WEBRTC_VIDEO_CODEC_OK;
17728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
17828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
17928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual int32 Release() {
18028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return WEBRTC_VIDEO_CODEC_OK;
18128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
18228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
18328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual int32 SetChannelParameters(uint32 packetLoss,
18428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                                     int rtt) {
18528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return WEBRTC_VIDEO_CODEC_OK;
18628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
18728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
18828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual int32 SetRates(uint32 newBitRate,
18928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                         uint32 frameRate) {
19028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return WEBRTC_VIDEO_CODEC_OK;
19128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
19228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org};
19328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
19428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org// Fake class for mocking out WebRtcVideoEncoderFactory.
19528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgclass FakeWebRtcVideoEncoderFactory : public WebRtcVideoEncoderFactory {
19628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org public:
19728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  FakeWebRtcVideoEncoderFactory()
19828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      : num_created_encoders_(0) {
19928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
20028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
20128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual webrtc::VideoEncoder* CreateVideoEncoder(
20228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      webrtc::VideoCodecType type) {
20328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (supported_codec_types_.count(type) == 0) {
20428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return NULL;
20528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
20628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    FakeWebRtcVideoEncoder* encoder = new FakeWebRtcVideoEncoder();
20728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    encoders_.push_back(encoder);
20828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    num_created_encoders_++;
20928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return encoder;
21028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
21128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
21228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual void DestroyVideoEncoder(webrtc::VideoEncoder* encoder) {
21328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    encoders_.erase(
21428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        std::remove(encoders_.begin(), encoders_.end(), encoder),
21528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        encoders_.end());
21628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    delete encoder;
21728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
21828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
21928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual void AddObserver(WebRtcVideoEncoderFactory::Observer* observer) {
22028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    bool inserted = observers_.insert(observer).second;
22128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    EXPECT_TRUE(inserted);
22228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
22328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
22428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual void RemoveObserver(WebRtcVideoEncoderFactory::Observer* observer) {
22528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    size_t erased = observers_.erase(observer);
22628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    EXPECT_EQ(erased, 1UL);
22728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
22828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
22928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual const std::vector<WebRtcVideoEncoderFactory::VideoCodec>& codecs()
23028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      const {
23128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return codecs_;
23228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
23328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
23428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  void AddSupportedVideoCodecType(webrtc::VideoCodecType type,
23528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                                  const std::string& name) {
23628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    supported_codec_types_.insert(type);
23728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    codecs_.push_back(
23828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        WebRtcVideoEncoderFactory::VideoCodec(type, name, 1280, 720, 30));
23928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
24028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
24128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  void NotifyCodecsAvailable() {
24228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    std::set<WebRtcVideoEncoderFactory::Observer*>::iterator it;
24328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    for (it = observers_.begin(); it != observers_.end(); ++it)
24428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      (*it)->OnCodecsAvailable();
24528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
24628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
247b884eb611803b4720e55bdd8b51602edf7061061wu@webrtc.org  int GetNumCreatedEncoders() {
248b884eb611803b4720e55bdd8b51602edf7061061wu@webrtc.org    return num_created_encoders_;
249b884eb611803b4720e55bdd8b51602edf7061061wu@webrtc.org  }
250b884eb611803b4720e55bdd8b51602edf7061061wu@webrtc.org
25128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  const std::vector<FakeWebRtcVideoEncoder*>& encoders() {
25228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return encoders_;
25328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
25428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
25528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org private:
25628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  std::set<webrtc::VideoCodecType> supported_codec_types_;
25728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  std::vector<WebRtcVideoEncoderFactory::VideoCodec> codecs_;
25828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  std::vector<FakeWebRtcVideoEncoder*> encoders_;
25928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  std::set<WebRtcVideoEncoderFactory::Observer*> observers_;
26028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int num_created_encoders_;
26128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org};
26228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
26328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgclass FakeWebRtcVideoEngine
26428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    : public webrtc::ViEBase,
26528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      public webrtc::ViECodec,
26628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      public webrtc::ViECapture,
26728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      public webrtc::ViENetwork,
26828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      public webrtc::ViERender,
26928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      public webrtc::ViERTP_RTCP,
27028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      public webrtc::ViEImageProcess,
27128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      public webrtc::ViEExternalCodec {
27228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org public:
27328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  struct Channel {
27428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    Channel()
27528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        : capture_id_(-1),
27628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          original_channel_id_(-1),
27728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          has_renderer_(false),
27828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          render_started_(false),
27928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          send(false),
28028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          receive_(false),
28128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          can_transmit_(true),
2825bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org          remote_rtx_ssrc_(-1),
2835bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org          rtx_send_payload_type(-1),
28428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          rtcp_status_(webrtc::kRtcpNone),
28528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          key_frame_request_method_(webrtc::kViEKeyFrameRequestNone),
28628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          tmmbr_(false),
28728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          remb_contribute_(false),
28828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          remb_bw_partition_(false),
28928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          rtp_offset_send_id_(0),
29028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          rtp_offset_receive_id_(0),
29128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          rtp_absolute_send_time_send_id_(0),
29228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          rtp_absolute_send_time_receive_id_(0),
29328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          sender_target_delay_(0),
29428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          receiver_target_delay_(0),
29528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          transmission_smoothing_(false),
29628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          nack_(false),
29728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          hybrid_nack_fec_(false),
29828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          send_video_bitrate_(0),
29928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          send_fec_bitrate_(0),
30028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          send_nack_bitrate_(0),
30128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          send_bandwidth_(0),
3026e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org          receive_bandwidth_(0),
3036e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org          suspend_below_min_bitrate_(false),
3046e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org          overuse_observer_(NULL) {
30528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      ssrcs_[0] = 0;  // default ssrc.
30628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      memset(&send_codec, 0, sizeof(send_codec));
307b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org#ifdef USE_WEBRTC_DEV_BRANCH
308b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org      memset(&overuse_options_, 0, sizeof(overuse_options_));
309b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org#endif
31028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
31128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int capture_id_;
31228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int original_channel_id_;
31328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    bool has_renderer_;
31428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    bool render_started_;
31528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    bool send;
31628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    bool receive_;
31728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    bool can_transmit_;
31828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    std::map<int, int> ssrcs_;
3195bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    std::map<int, int> rtx_ssrcs_;
3205bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    int remote_rtx_ssrc_;
3215bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    int rtx_send_payload_type;
32228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    std::string cname_;
32328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    webrtc::ViERTCPMode rtcp_status_;
32428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    webrtc::ViEKeyFrameRequestMethod key_frame_request_method_;
32528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    bool tmmbr_;
32628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    bool remb_contribute_;   // This channel contributes to the remb report.
32728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    bool remb_bw_partition_; // This channel is allocated part of total bw.
32828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int rtp_offset_send_id_;
32928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int rtp_offset_receive_id_;
33028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int rtp_absolute_send_time_send_id_;
33128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int rtp_absolute_send_time_receive_id_;
33228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int sender_target_delay_;
33328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int receiver_target_delay_;
33428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    bool transmission_smoothing_;
33528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    bool nack_;
33628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    bool hybrid_nack_fec_;
33728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    std::vector<webrtc::VideoCodec> recv_codecs;
33828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    std::set<unsigned int> ext_decoder_pl_types_;
33928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    std::set<unsigned int> ext_encoder_pl_types_;
34028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    webrtc::VideoCodec send_codec;
34128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    unsigned int send_video_bitrate_;
34228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    unsigned int send_fec_bitrate_;
34328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    unsigned int send_nack_bitrate_;
34428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    unsigned int send_bandwidth_;
34528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    unsigned int receive_bandwidth_;
3466e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org    bool suspend_below_min_bitrate_;
3476e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org    webrtc::CpuOveruseObserver* overuse_observer_;
348b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org#ifdef USE_WEBRTC_DEV_BRANCH
349b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org    webrtc::CpuOveruseOptions overuse_options_;
350b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org#endif
35128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
35228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  class Capturer : public webrtc::ViEExternalCapture {
35328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org   public:
35424301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org    Capturer() : channel_id_(-1), denoising_(false),
35524301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org                 last_capture_time_(0), incoming_frame_num_(0) { }
35628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int channel_id() const { return channel_id_; }
35728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    void set_channel_id(int channel_id) { channel_id_ = channel_id; }
35828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    bool denoising() const { return denoising_; }
35928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    void set_denoising(bool denoising) { denoising_ = denoising; }
36024301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org    int64 last_capture_time() const { return last_capture_time_; }
36124301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org    int incoming_frame_num() const { return incoming_frame_num_; }
36228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
36328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    // From ViEExternalCapture
36428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    virtual int IncomingFrame(unsigned char* videoFrame,
36528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                              unsigned int videoFrameLength,
36628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                              unsigned short width,
36728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                              unsigned short height,
36828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                              webrtc::RawVideoType videoType,
36928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                              unsigned long long captureTime) {
37028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return 0;
37128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
37228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    virtual int IncomingFrameI420(
37328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        const webrtc::ViEVideoFrameI420& video_frame,
37428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        unsigned long long captureTime) {
37528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      last_capture_time_ = captureTime;
37624301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org      ++incoming_frame_num_;
37728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return 0;
37828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
37928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
38028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org   private:
38128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int channel_id_;
38228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    bool denoising_;
38328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int64 last_capture_time_;
38424301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org    int incoming_frame_num_;
38528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
38628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
38728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  FakeWebRtcVideoEngine(const cricket::VideoCodec* const* codecs,
38828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                        int num_codecs)
38928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      : inited_(false),
39028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        last_channel_(kViEChannelIdBase - 1),
39128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        fail_create_channel_(false),
39228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        last_capturer_(kViECaptureIdBase - 1),
39328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        fail_alloc_capturer_(false),
39428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        codecs_(codecs),
39528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        num_codecs_(num_codecs),
39628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        num_set_send_codecs_(0) {
39728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
39828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
39928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  ~FakeWebRtcVideoEngine() {
40028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    ASSERT(0 == channels_.size());
40128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    ASSERT(0 == capturers_.size());
40228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
40328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool IsInited() const { return inited_; }
40428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
40528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetLastChannel() const { return last_channel_; }
40628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetChannelFromLocalSsrc(int local_ssrc) const {
40728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    // ssrcs_[0] is the default local ssrc.
40828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    for (std::map<int, Channel*>::const_iterator iter = channels_.begin();
40928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org         iter != channels_.end(); ++iter) {
41028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      if (local_ssrc == iter->second->ssrcs_[0]) {
41128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        return iter->first;
41228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      }
41328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
41428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return -1;
41528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
41628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
41728654cbc2256230c978f41cbaf550bc2e9c2f2dbhenrike@webrtc.org  int GetNumChannels() const { return static_cast<int>(channels_.size()); }
41828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool IsChannel(int channel) const {
41928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return (channels_.find(channel) != channels_.end());
42028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
42128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  void set_fail_create_channel(bool fail_create_channel) {
42228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    fail_create_channel_ = fail_create_channel;
42328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
42428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
42528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetLastCapturer() const { return last_capturer_; }
42628654cbc2256230c978f41cbaf550bc2e9c2f2dbhenrike@webrtc.org  int GetNumCapturers() const { return static_cast<int>(capturers_.size()); }
42724301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org  int GetIncomingFrameNum(int channel_id) const {
42824301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org    for (std::map<int, Capturer*>::const_iterator iter = capturers_.begin();
42924301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org         iter != capturers_.end(); ++iter) {
43024301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org      Capturer* capturer = iter->second;
43124301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org      if (capturer->channel_id() == channel_id) {
43224301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org        return capturer->incoming_frame_num();
43324301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org      }
43424301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org    }
43524301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org    return -1;
43624301a67c66e6091418e83da49cfb367ef2c6645wu@webrtc.org  }
43728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  void set_fail_alloc_capturer(bool fail_alloc_capturer) {
43828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    fail_alloc_capturer_ = fail_alloc_capturer;
43928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
44005e7b44b83f9f12a827646c496f5d6ae796b4b99wu@webrtc.org  int GetNumSetSendCodecs() const { return num_set_send_codecs_; }
44128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
44228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetCaptureId(int channel) const {
44328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
44428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->capture_id_;
44528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
44628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetOriginalChannelId(int channel) const {
44728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
44828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->original_channel_id_;
44928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
45028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool GetHasRenderer(int channel) const {
45128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
45228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->has_renderer_;
45328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
45428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool GetRenderStarted(int channel) const {
45528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
45628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->render_started_;
45728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
45828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool GetSend(int channel) const {
45928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
46028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->send;
46128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
462b9a088b920d1ba16e0593698d4a613bb7bb5481fwu@webrtc.org  bool GetReceive(int channel) const {
463b9a088b920d1ba16e0593698d4a613bb7bb5481fwu@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
464b9a088b920d1ba16e0593698d4a613bb7bb5481fwu@webrtc.org    return channels_.find(channel)->second->receive_;
465b9a088b920d1ba16e0593698d4a613bb7bb5481fwu@webrtc.org  }
46628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetCaptureChannelId(int capture_id) const {
46728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CAPTURER(capture_id);
46828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return capturers_.find(capture_id)->second->channel_id();
46928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
47028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool GetCaptureDenoising(int capture_id) const {
47128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CAPTURER(capture_id);
47228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return capturers_.find(capture_id)->second->denoising();
47328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
47428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int64 GetCaptureLastTimestamp(int capture_id) const {
47528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CAPTURER(capture_id);
47628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return capturers_.find(capture_id)->second->last_capture_time();
47728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
47828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  webrtc::ViERTCPMode GetRtcpStatus(int channel) const {
47928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
48028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->rtcp_status_;
48128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
48228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  webrtc::ViEKeyFrameRequestMethod GetKeyFrameRequestMethod(int channel) const {
48328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
48428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->key_frame_request_method_;
48528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
48628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool GetTmmbrStatus(int channel) const {
48728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
48828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->tmmbr_;
48928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
49028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool GetRembStatusBwPartition(int channel) const {
49128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
49228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->remb_bw_partition_;
49328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
49428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool GetRembStatusContribute(int channel) const {
49528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
49628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->remb_contribute_;
49728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
49828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetSendRtpTimestampOffsetExtensionId(int channel) {
49928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
50028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->rtp_offset_send_id_;
50128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
50228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetReceiveRtpTimestampOffsetExtensionId(int channel) {
50328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
50428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->rtp_offset_receive_id_;
50528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
50628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetSendAbsoluteSendTimeExtensionId(int channel) {
50728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
50828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->rtp_absolute_send_time_send_id_;
50928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
51028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetReceiveAbsoluteSendTimeExtensionId(int channel) {
51128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
51228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->rtp_absolute_send_time_receive_id_;
51328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
51428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool GetTransmissionSmoothingStatus(int channel) {
51528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
51628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->transmission_smoothing_;
51728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
51828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetSenderTargetDelay(int channel) {
51928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
52028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->sender_target_delay_;
52128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
52228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetReceiverTargetDelay(int channel) {
52328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
52428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->receiver_target_delay_;
52528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
52628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool GetNackStatus(int channel) const {
52728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
52828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->nack_;
52928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
53028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool GetHybridNackFecStatus(int channel) const {
53128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
53228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->hybrid_nack_fec_;
53328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
53428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetNumSsrcs(int channel) const {
53528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
53628654cbc2256230c978f41cbaf550bc2e9c2f2dbhenrike@webrtc.org    return static_cast<int>(
53728654cbc2256230c978f41cbaf550bc2e9c2f2dbhenrike@webrtc.org        channels_.find(channel)->second->ssrcs_.size());
53828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
5395bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  int GetNumRtxSsrcs(int channel) const {
5405bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    WEBRTC_ASSERT_CHANNEL(channel);
5415bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    return static_cast<int>(
5425bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org        channels_.find(channel)->second->rtx_ssrcs_.size());
5435bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  }
54428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool GetIsTransmitting(int channel) const {
54528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
54628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->can_transmit_;
54728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
5486e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org  webrtc::CpuOveruseObserver* GetCpuOveruseObserver(int channel) const {
5496e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
5506e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org    return channels_.find(channel)->second->overuse_observer_;
5516e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org  }
552b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org#ifdef USE_WEBRTC_DEV_BRANCH
553b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org  webrtc::CpuOveruseOptions GetCpuOveruseOptions(int channel) const {
554b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
555b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org    return channels_.find(channel)->second->overuse_options_;
556b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org  }
557b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org#endif
5585bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  int GetRtxSsrc(int channel, int simulcast_idx) const {
5595bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    WEBRTC_ASSERT_CHANNEL(channel);
5605bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    if (channels_.find(channel)->second->rtx_ssrcs_.find(simulcast_idx) ==
5615bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org        channels_.find(channel)->second->rtx_ssrcs_.end()) {
5625bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org      return -1;
5635bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    }
5645bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    return channels_.find(channel)->second->rtx_ssrcs_[simulcast_idx];
5655bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  }
56628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool ReceiveCodecRegistered(int channel,
56728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                              const webrtc::VideoCodec& codec) const {
56828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
5691e6cb2c5d21d778437e650170de397ace4b39b08wu@webrtc.org#if !defined(USE_WEBRTC_DEV_BRANCH)
57028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    const std::vector<webrtc::VideoCodec>& codecs =
57128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      channels_.find(channel)->second->recv_codecs;
57228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return std::find(codecs.begin(), codecs.end(), codec) != codecs.end();
5731e6cb2c5d21d778437e650170de397ace4b39b08wu@webrtc.org#else
5741e6cb2c5d21d778437e650170de397ace4b39b08wu@webrtc.org    // TODO(mallinath) - Remove this specilization after this change is pushed
5751e6cb2c5d21d778437e650170de397ace4b39b08wu@webrtc.org    // to googlecode and operator== from VideoCodecDerived moved inside
5761e6cb2c5d21d778437e650170de397ace4b39b08wu@webrtc.org    // VideoCodec.
5771e6cb2c5d21d778437e650170de397ace4b39b08wu@webrtc.org    return true;
5781e6cb2c5d21d778437e650170de397ace4b39b08wu@webrtc.org#endif
57928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
58028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool ExternalDecoderRegistered(int channel,
58128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                                 unsigned int pl_type) const {
58228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
58328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->
58428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        ext_decoder_pl_types_.count(pl_type) != 0;
58528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
58628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetNumExternalDecoderRegistered(int channel) const {
58728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
58828654cbc2256230c978f41cbaf550bc2e9c2f2dbhenrike@webrtc.org    return static_cast<int>(
58928654cbc2256230c978f41cbaf550bc2e9c2f2dbhenrike@webrtc.org        channels_.find(channel)->second->ext_decoder_pl_types_.size());
59028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
59128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool ExternalEncoderRegistered(int channel,
59228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                                 unsigned int pl_type) const {
59328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
59428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return channels_.find(channel)->second->
59528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        ext_encoder_pl_types_.count(pl_type) != 0;
59628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
59728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetNumExternalEncoderRegistered(int channel) const {
59828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
59928654cbc2256230c978f41cbaf550bc2e9c2f2dbhenrike@webrtc.org    return static_cast<int>(
60028654cbc2256230c978f41cbaf550bc2e9c2f2dbhenrike@webrtc.org        channels_.find(channel)->second->ext_encoder_pl_types_.size());
60128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
60228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int GetTotalNumExternalEncoderRegistered() const {
60328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    std::map<int, Channel*>::const_iterator it;
60428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int total_num_registered = 0;
60528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    for (it = channels_.begin(); it != channels_.end(); ++it)
60628654cbc2256230c978f41cbaf550bc2e9c2f2dbhenrike@webrtc.org      total_num_registered +=
60728654cbc2256230c978f41cbaf550bc2e9c2f2dbhenrike@webrtc.org          static_cast<int>(it->second->ext_encoder_pl_types_.size());
60828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return total_num_registered;
60928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
61028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  void SetSendBitrates(int channel, unsigned int video_bitrate,
61128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                       unsigned int fec_bitrate, unsigned int nack_bitrate) {
61228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
61328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->send_video_bitrate_ = video_bitrate;
61428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->send_fec_bitrate_ = fec_bitrate;
61528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->send_nack_bitrate_ = nack_bitrate;
61628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
61728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  void SetSendBandwidthEstimate(int channel, unsigned int send_bandwidth) {
61828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
61928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->send_bandwidth_ = send_bandwidth;
62028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
62128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  void SetReceiveBandwidthEstimate(int channel,
62228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                                   unsigned int receive_bandwidth) {
62328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
62428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->receive_bandwidth_ = receive_bandwidth;
62528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
6265bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  int GetRtxSendPayloadType(int channel) {
6275bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    WEBRTC_CHECK_CHANNEL(channel);
6285bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    return channels_[channel]->rtx_send_payload_type;
6295bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  }
6305bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  int GetRemoteRtxSsrc(int channel) {
6315bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    WEBRTC_CHECK_CHANNEL(channel);
6325bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    return channels_.find(channel)->second->remote_rtx_ssrc_;
6335bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  }
6346e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org  bool GetSuspendBelowMinBitrateStatus(int channel) {
6356e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
6366e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org    return channels_.find(channel)->second->suspend_below_min_bitrate_;
6376e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org  }
63828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
63928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(Release, ());
64028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
64128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // webrtc::ViEBase
64228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(Init, ()) {
64328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    inited_ = true;
64428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
64528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
64628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(SetVoiceEngine, (webrtc::VoiceEngine*));
64728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(CreateChannel, (int& channel)) {  // NOLINT
64828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (fail_create_channel_) {
64928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return -1;
65028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
65128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (kViEChannelIdMax == last_channel_) {
65228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return -1;
65328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
65428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    Channel* ch = new Channel();
65528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[++last_channel_] = ch;
65628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channel = last_channel_;
65728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
65828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
65928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(CreateChannel, (int& channel, int original_channel)) {
66028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(original_channel);
66128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (CreateChannel(channel) != 0) {
66228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return -1;
66328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
66428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->original_channel_id_ = original_channel;
66528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
66628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
66728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(CreateReceiveChannel, (int& channel, int original_channel)) {
66828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return CreateChannel(channel, original_channel);
66928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
67028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(DeleteChannel, (const int channel)) {
67128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
67228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    // Make sure we deregister all the decoders before deleting a channel.
67328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    EXPECT_EQ(0, GetNumExternalDecoderRegistered(channel));
67428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    delete channels_[channel];
67528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_.erase(channel);
67628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
67728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
6786e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org  WEBRTC_FUNC(RegisterCpuOveruseObserver,
6796e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org      (int channel, webrtc::CpuOveruseObserver* observer)) {
6806e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
6816e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org    channels_[channel]->overuse_observer_ = observer;
6826e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org    return 0;
6836e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org  }
6849caf2765b285f7511d8355177c2d55209d7573e4wu@webrtc.org  WEBRTC_STUB(CpuOveruseMeasures, (int, int*, int*, int*, int*));
685b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org#ifdef USE_WEBRTC_DEV_BRANCH
686b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org  WEBRTC_FUNC(SetCpuOveruseOptions,
687b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org      (int channel, const webrtc::CpuOveruseOptions& options)) {
688b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
689b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org    channels_[channel]->overuse_options_ = options;
690b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org    return 0;
691b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org  }
692b0ecc1c6fb107b9032611870eeae8afde3e0a5d2henrike@webrtc.org#endif
69328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(ConnectAudioChannel, (const int, const int));
69428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(DisconnectAudioChannel, (const int));
69528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(StartSend, (const int channel)) {
69628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
69728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->send = true;
69828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
69928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
70028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(StopSend, (const int channel)) {
70128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
70228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->send = false;
70328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
70428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
70528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(StartReceive, (const int channel)) {
70628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
70728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->receive_ = true;
70828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
70928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
71028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(StopReceive, (const int channel)) {
71128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
71228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->receive_ = false;
71328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
71428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
71528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(GetVersion, (char version[1024]));
71628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(LastError, ());
71728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
71828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // webrtc::ViECodec
71928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC_CONST(NumberOfCodecs, ()) {
72028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return num_codecs_;
72128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
72228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC_CONST(GetCodec, (const unsigned char list_number,
72328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                               webrtc::VideoCodec& out_codec)) {
72428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (list_number >= NumberOfCodecs()) {
72528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return -1;
72628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
72728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    memset(&out_codec, 0, sizeof(out_codec));
72828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    const cricket::VideoCodec& c(*codecs_[list_number]);
72928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if ("I420" == c.name) {
73028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      out_codec.codecType = webrtc::kVideoCodecI420;
73128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    } else if ("VP8" == c.name) {
73228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      out_codec.codecType = webrtc::kVideoCodecVP8;
73328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    } else if ("red" == c.name) {
73428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      out_codec.codecType = webrtc::kVideoCodecRED;
73528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    } else if ("ulpfec" == c.name) {
73628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      out_codec.codecType = webrtc::kVideoCodecULPFEC;
73728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    } else {
73828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      out_codec.codecType = webrtc::kVideoCodecUnknown;
73928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
74028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    talk_base::strcpyn(out_codec.plName, sizeof(out_codec.plName),
74128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                       c.name.c_str());
74228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    out_codec.plType = c.id;
74328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    out_codec.width = c.width;
74428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    out_codec.height = c.height;
74528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    out_codec.startBitrate = kStartVideoBitrate;
74628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    out_codec.maxBitrate = kMaxVideoBitrate;
74728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    out_codec.minBitrate = kMinVideoBitrate;
74828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    out_codec.maxFramerate = c.framerate;
74928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
75028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
75128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetSendCodec, (const int channel,
75228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                             const webrtc::VideoCodec& codec)) {
75328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
75428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->send_codec = codec;
75528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    ++num_set_send_codecs_;
75628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
75728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
75828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC_CONST(GetSendCodec, (const int channel,
75928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                                   webrtc::VideoCodec& codec)) {  // NOLINT
76028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
76128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    codec = channels_.find(channel)->second->send_codec;
76228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
76328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
76428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetReceiveCodec, (const int channel,
76528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                                const webrtc::VideoCodec& codec)) {  // NOLINT
76628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
76728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->recv_codecs.push_back(codec);
76828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
76928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  };
77028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB_CONST(GetReceiveCodec, (const int, webrtc::VideoCodec&));
77128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB_CONST(GetCodecConfigParameters, (const int,
77228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      unsigned char*, unsigned char&));
77328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(SetImageScaleStatus, (const int, const bool));
77428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB_CONST(GetSendCodecStastistics, (const int,
77528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      unsigned int&, unsigned int&));
77628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB_CONST(GetReceiveCodecStastistics, (const int,
77728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      unsigned int&, unsigned int&));
77828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB_CONST(GetReceiveSideDelay, (const int video_channel,
77928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                                          int* delay_ms));
78028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC_CONST(GetCodecTargetBitrate, (const int channel,
78128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      unsigned int* codec_target_bitrate)) {
78228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
78328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
78428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    std::map<int, Channel*>::const_iterator it = channels_.find(channel);
78528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (it->second->send) {
78628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      // Assume the encoder produces the expected rate.
78728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      *codec_target_bitrate = it->second->send_video_bitrate_;
78828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    } else {
78928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      *codec_target_bitrate = 0;
79028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
79128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
79228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
79328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual unsigned int GetDiscardedPackets(const int channel) const {
79428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
79528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
79628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
79728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(SetKeyFrameRequestCallbackStatus, (const int, const bool));
79828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(SetSignalKeyPacketLossStatus, (const int, const bool,
79928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      const bool));
80028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(RegisterEncoderObserver, (const int,
80128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      webrtc::ViEEncoderObserver&));
80228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(DeregisterEncoderObserver, (const int));
80328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(RegisterDecoderObserver, (const int,
80428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      webrtc::ViEDecoderObserver&));
80528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(DeregisterDecoderObserver, (const int));
80628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(SendKeyFrame, (const int));
80728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(WaitForFirstKeyFrame, (const int, const bool));
8089de257d00f1f805af28f15fd814a8a84460028e5henrike@webrtc.org  WEBRTC_STUB(StartDebugRecording, (int, const char*));
8099de257d00f1f805af28f15fd814a8a84460028e5henrike@webrtc.org  WEBRTC_STUB(StopDebugRecording, (int));
8106e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org  WEBRTC_VOID_FUNC(SuspendBelowMinBitrate, (int channel)) {
8116e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
8126e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org    channels_[channel]->suspend_below_min_bitrate_ = true;
8136e3dbc2a77eb96b050c4909c4206348f1b15550chenrike@webrtc.org  }
81428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
81528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // webrtc::ViECapture
81628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(NumberOfCaptureDevices, ());
81728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(GetCaptureDevice, (unsigned int, char*,
81828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      const unsigned int, char*, const unsigned int));
81928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(AllocateCaptureDevice, (const char*, const unsigned int, int&));
82028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(AllocateExternalCaptureDevice,
82128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org              (int& capture_id, webrtc::ViEExternalCapture*& capture)) {
82228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (fail_alloc_capturer_) {
82328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return -1;
82428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
82528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (kViECaptureIdMax == last_capturer_) {
82628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return -1;
82728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
82828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    Capturer* cap = new Capturer();
82928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    capturers_[++last_capturer_] = cap;
83028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    capture_id = last_capturer_;
83128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    capture = cap;
83228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
83328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
83428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(AllocateCaptureDevice, (webrtc::VideoCaptureModule&, int&));
83528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(ReleaseCaptureDevice, (const int capture_id)) {
83628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CAPTURER(capture_id);
83728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    delete capturers_[capture_id];
83828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    capturers_.erase(capture_id);
83928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
84028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
84128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(ConnectCaptureDevice, (const int capture_id,
84228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                                     const int channel)) {
84328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
84428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CAPTURER(capture_id);
84528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->capture_id_ = capture_id;
84628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    capturers_[capture_id]->set_channel_id(channel);
84728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
84828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
84928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(DisconnectCaptureDevice, (const int channel)) {
85028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
85128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    int capture_id = channels_[channel]->capture_id_;
85228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CAPTURER(capture_id);
85328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->capture_id_ = -1;
85428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    capturers_[capture_id]->set_channel_id(-1);
85528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
85628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
85728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(StartCapture, (const int, const webrtc::CaptureCapability&));
85828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(StopCapture, (const int));
85928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(SetRotateCapturedFrames, (const int,
86028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      const webrtc::RotateCapturedFrame));
86128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(SetCaptureDelay, (const int, const unsigned int));
86228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(NumberOfCapabilities, (const char*, const unsigned int));
86328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(GetCaptureCapability, (const char*, const unsigned int,
86428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      const unsigned int, webrtc::CaptureCapability&));
86528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(ShowCaptureSettingsDialogBox, (const char*, const unsigned int,
86628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      const char*, void*, const unsigned int, const unsigned int));
86728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(GetOrientation, (const char*, webrtc::RotateCapturedFrame&));
86828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(EnableBrightnessAlarm, (const int, const bool));
86928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(RegisterObserver, (const int, webrtc::ViECaptureObserver&));
87028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(DeregisterObserver, (const int));
87128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
87228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // webrtc::ViENetwork
87328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_VOID_FUNC(SetNetworkTransmissionState, (const int channel,
87428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                                                 const bool is_transmitting)) {
87528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_ASSERT_CHANNEL(channel);
87628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->can_transmit_ = is_transmitting;
87728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
87828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(RegisterSendTransport, (const int, webrtc::Transport&));
87928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(DeregisterSendTransport, (const int));
880a9890800e078105f21f0a21358ee59a0b3736af6wu@webrtc.org  WEBRTC_STUB(ReceivedRTPPacket, (const int, const void*, const int,
881a9890800e078105f21f0a21358ee59a0b3736af6wu@webrtc.org      const webrtc::PacketTime&));
88228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(ReceivedRTCPPacket, (const int, const void*, const int));
88328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // Not using WEBRTC_STUB due to bool return value
88428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  virtual bool IsIPv6Enabled(int channel) { return true; }
88528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(SetMTU, (int, unsigned int));
88628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
88728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // webrtc::ViERender
88828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(RegisterVideoRenderModule, (webrtc::VideoRender&));
88928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(DeRegisterVideoRenderModule, (webrtc::VideoRender&));
89028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(AddRenderer, (const int, void*, const unsigned int, const float,
89128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      const float, const float, const float));
89228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(RemoveRenderer, (const int render_id)) {
89328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (IsCapturerId(render_id)) {
89428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      WEBRTC_CHECK_CAPTURER(render_id);
89528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return 0;
89628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    } else if (IsChannelId(render_id)) {
89728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      WEBRTC_CHECK_CHANNEL(render_id);
89828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      channels_[render_id]->has_renderer_ = false;
89928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return 0;
90028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
90128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return -1;
90228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
90328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(StartRender, (const int render_id)) {
90428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (IsCapturerId(render_id)) {
90528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      WEBRTC_CHECK_CAPTURER(render_id);
90628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return 0;
90728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    } else if (IsChannelId(render_id)) {
90828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      WEBRTC_CHECK_CHANNEL(render_id);
90928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      channels_[render_id]->render_started_ = true;
91028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return 0;
91128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
91228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return -1;
91328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
91428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(StopRender, (const int render_id)) {
91528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (IsCapturerId(render_id)) {
91628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      WEBRTC_CHECK_CAPTURER(render_id);
91728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return 0;
91828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    } else if (IsChannelId(render_id)) {
91928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      WEBRTC_CHECK_CHANNEL(render_id);
92028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      channels_[render_id]->render_started_ = false;
92128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return 0;
92228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
92328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return -1;
92428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
92528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(SetExpectedRenderDelay, (int render_id, int render_delay));
92628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(ConfigureRender, (int, const unsigned int, const float,
92728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      const float, const float, const float));
92828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(MirrorRenderStream, (const int, const bool, const bool,
92928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      const bool));
93028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(AddRenderer, (const int render_id,
93128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                            webrtc::RawVideoType video_type,
93228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                            webrtc::ExternalRenderer* renderer)) {
93328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (IsCapturerId(render_id)) {
93428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      WEBRTC_CHECK_CAPTURER(render_id);
93528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return 0;
93628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    } else if (IsChannelId(render_id)) {
93728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      WEBRTC_CHECK_CHANNEL(render_id);
93828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      channels_[render_id]->has_renderer_ = true;
93928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return 0;
94028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
94128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return -1;
94228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
94328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
94428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // webrtc::ViERTP_RTCP
94528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetLocalSSRC, (const int channel,
94628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                             const unsigned int ssrc,
94728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                             const webrtc::StreamType usage,
94828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                             const unsigned char idx)) {
94928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
9505bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    switch (usage) {
9515bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org      case webrtc::kViEStreamTypeNormal:
9525bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org        channels_[channel]->ssrcs_[idx] = ssrc;
9535bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org        break;
9545bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org      case webrtc::kViEStreamTypeRtx:
9555bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org        channels_[channel]->rtx_ssrcs_[idx] = ssrc;
9565bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org        break;
9575bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org      default:
9585bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org        return -1;
9595bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    }
96028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
96128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
9625bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org
9635bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_FUNC_CONST(SetRemoteSSRCType, (const int channel,
9645bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org        const webrtc::StreamType usage, const unsigned int ssrc)) {
9655bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    WEBRTC_CHECK_CHANNEL(channel);
9665bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    if (usage == webrtc::kViEStreamTypeRtx) {
9675bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org      channels_.find(channel)->second->remote_rtx_ssrc_ = ssrc;
9685bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org      return 0;
9695bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    }
9705bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    return -1;
9715bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  }
97228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
97328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC_CONST(GetLocalSSRC, (const int channel,
97428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                                   unsigned int& ssrc)) {
97528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    // ssrcs_[0] is the default local ssrc.
97628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
97728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    ssrc = channels_.find(channel)->second->ssrcs_[0];
97828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
97928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
98028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB_CONST(GetRemoteSSRC, (const int, unsigned int&));
98128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB_CONST(GetRemoteCSRCs, (const int, unsigned int*));
98228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
9835bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_FUNC(SetRtxSendPayloadType, (const int channel,
9845bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org                                      const uint8 payload_type)) {
9855bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    WEBRTC_CHECK_CHANNEL(channel);
9865bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    channels_[channel]->rtx_send_payload_type = payload_type;
9875bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org    return 0;
9885bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  }
98928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(SetRtxReceivePayloadType, (const int, const uint8));
99028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
99128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(SetStartSequenceNumber, (const int, unsigned short));
99228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetRTCPStatus,
99328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org              (const int channel, const webrtc::ViERTCPMode mode)) {
99428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
99528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->rtcp_status_ = mode;
99628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
99728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
99828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB_CONST(GetRTCPStatus, (const int, webrtc::ViERTCPMode&));
99928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetRTCPCName, (const int channel,
100028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                             const char rtcp_cname[KMaxRTCPCNameLength])) {
100128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
100228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->cname_.assign(rtcp_cname);
100328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
100428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
100528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC_CONST(GetRTCPCName, (const int channel,
100628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                                   char rtcp_cname[KMaxRTCPCNameLength])) {
100728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
100828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    talk_base::strcpyn(rtcp_cname, KMaxRTCPCNameLength,
100928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org                       channels_.find(channel)->second->cname_.c_str());
101028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
101128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
101228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB_CONST(GetRemoteRTCPCName, (const int, char*));
101328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(SendApplicationDefinedRTCPPacket, (const int, const unsigned char,
101428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      unsigned int, const char*, unsigned short));
101528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetNACKStatus, (const int channel, const bool enable)) {
101628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
101728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->nack_ = enable;
101828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->hybrid_nack_fec_ = false;
101928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
102028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
102128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(SetFECStatus, (const int, const bool, const unsigned char,
102228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      const unsigned char));
102328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetHybridNACKFECStatus, (const int channel, const bool enable,
102428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      const unsigned char red_type, const unsigned char fec_type)) {
102528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
102628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (red_type == fec_type ||
102728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        red_type == channels_[channel]->send_codec.plType ||
102828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org        fec_type == channels_[channel]->send_codec.plType) {
102928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      return -1;
103028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
103128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->nack_ = false;
103228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->hybrid_nack_fec_ = enable;
103328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
103428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
103528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetKeyFrameRequestMethod,
103628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org              (const int channel,
103728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org               const webrtc::ViEKeyFrameRequestMethod method)) {
103828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
103928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->key_frame_request_method_ = method;
104028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
104128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
104228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetSenderBufferingMode, (int channel, int target_delay)) {
104328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
104428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->sender_target_delay_ = target_delay;
104528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
104628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
104728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetReceiverBufferingMode, (int channel, int target_delay)) {
104828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
104928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->receiver_target_delay_ = target_delay;
105028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
105128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
105228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // |Send| and |receive| are stored locally in variables that more clearly
105328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // explain what they mean.
105428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetRembStatus, (int channel, bool send, bool receive)) {
105528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
105628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->remb_contribute_ = receive;
105728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->remb_bw_partition_ = send;
105828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
105928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
106028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetTMMBRStatus, (const int channel, const bool enable)) {
106128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
106228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->tmmbr_ = enable;
106328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
106428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
106528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetSendTimestampOffsetStatus, (int channel, bool enable,
106628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      int id)) {
106728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
106828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->rtp_offset_send_id_ = (enable) ? id : 0;
106928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
107028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
107128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetReceiveTimestampOffsetStatus, (int channel, bool enable,
107228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      int id)) {
107328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
107428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->rtp_offset_receive_id_ = (enable) ? id : 0;
107528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
107628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
107728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetSendAbsoluteSendTimeStatus, (int channel, bool enable,
107828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      int id)) {
107928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
108028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->rtp_absolute_send_time_send_id_ = (enable) ? id : 0;
108128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
108228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
108328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetReceiveAbsoluteSendTimeStatus, (int channel, bool enable,
108428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      int id)) {
108528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
108628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->rtp_absolute_send_time_receive_id_ = (enable) ? id : 0;
108728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
108828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
10899caf2765b285f7511d8355177c2d55209d7573e4wu@webrtc.org  WEBRTC_STUB(SetRtcpXrRrtrStatus, (int, bool));
109028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(SetTransmissionSmoothingStatus, (int channel, bool enable)) {
109128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
109228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->transmission_smoothing_ = enable;
109328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
109428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
1095704bf9ebec9c9425e1898f6c3f15eff685175b23henrike@webrtc.org#ifdef USE_WEBRTC_DEV_BRANCH
1096704bf9ebec9c9425e1898f6c3f15eff685175b23henrike@webrtc.org  WEBRTC_STUB_CONST(GetRtcpPacketTypeCounters, (int,
1097704bf9ebec9c9425e1898f6c3f15eff685175b23henrike@webrtc.org      webrtc::RtcpPacketTypeCounter*, webrtc::RtcpPacketTypeCounter*));
1098704bf9ebec9c9425e1898f6c3f15eff685175b23henrike@webrtc.org#endif
109928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB_CONST(GetReceivedRTCPStatistics, (const int, unsigned short&,
110028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      unsigned int&, unsigned int&, unsigned int&, int&));
110128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB_CONST(GetSentRTCPStatistics, (const int, unsigned short&,
110228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      unsigned int&, unsigned int&, unsigned int&, int&));
110328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB_CONST(GetRTPStatistics, (const int, unsigned int&, unsigned int&,
110428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      unsigned int&, unsigned int&));
11055bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB_CONST(GetReceiveChannelRtcpStatistics, (const int,
11065bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org      webrtc::RtcpStatistics&, int&));
11075bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB_CONST(GetSendChannelRtcpStatistics, (const int,
11085bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org      webrtc::RtcpStatistics&, int&));
11095bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB_CONST(GetRtpStatistics, (const int, webrtc::StreamDataCounters&,
11105bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org      webrtc::StreamDataCounters&));
111128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC_CONST(GetBandwidthUsage, (const int channel,
111228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      unsigned int& total_bitrate, unsigned int& video_bitrate,
111328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      unsigned int& fec_bitrate, unsigned int& nack_bitrate)) {
111428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
111528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    std::map<int, Channel*>::const_iterator it = channels_.find(channel);
111628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (it->second->send) {
111728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      video_bitrate = it->second->send_video_bitrate_;
111828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      fec_bitrate = it->second->send_fec_bitrate_;
111928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      nack_bitrate = it->second->send_nack_bitrate_;
112028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      total_bitrate = video_bitrate + fec_bitrate + nack_bitrate;
112128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    } else {
112228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      total_bitrate = 0;
112328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      video_bitrate = 0;
112428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      fec_bitrate = 0;
112528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      nack_bitrate = 0;
112628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
112728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
112828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
112928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC_CONST(GetEstimatedSendBandwidth, (const int channel,
113028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      unsigned int* send_bandwidth_estimate)) {
113128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
113228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    std::map<int, Channel*>::const_iterator it = channels_.find(channel);
113328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    // Assume the current video, fec and nack bitrate sums up to our estimate.
113428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (it->second->send) {
113528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      *send_bandwidth_estimate = it->second->send_bandwidth_;
113628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    } else {
113728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      *send_bandwidth_estimate = 0;
113828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
113928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
114028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
114128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC_CONST(GetEstimatedReceiveBandwidth, (const int channel,
114228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      unsigned int* receive_bandwidth_estimate)) {
114328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
114428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    std::map<int, Channel*>::const_iterator it = channels_.find(channel);
114528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    if (it->second->receive_) {
114628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    // For simplicity, assume all channels receive half of max send rate.
114728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      *receive_bandwidth_estimate = it->second->receive_bandwidth_;
114828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    } else {
114928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      *receive_bandwidth_estimate = 0;
115028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    }
115128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
115228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
11535bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB(RegisterSendChannelRtcpStatisticsCallback,
11545bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org                    (int, webrtc::RtcpStatisticsCallback*));
11555bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB(DeregisterSendChannelRtcpStatisticsCallback,
11565bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org                    (int, webrtc::RtcpStatisticsCallback*));
11575bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB(RegisterReceiveChannelRtcpStatisticsCallback,
11585bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org                    (int, webrtc::RtcpStatisticsCallback*));
11595bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB(DeregisterReceiveChannelRtcpStatisticsCallback,
11605bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org                    (int, webrtc::RtcpStatisticsCallback*));
11615bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB(RegisterSendChannelRtpStatisticsCallback,
11625bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org                    (int, webrtc::StreamDataCountersCallback*));
11635bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB(DeregisterSendChannelRtpStatisticsCallback,
11645bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org                    (int, webrtc::StreamDataCountersCallback*));
11655bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB(RegisterReceiveChannelRtpStatisticsCallback,
11665bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org                    (int, webrtc::StreamDataCountersCallback*));
11675bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB(DeregisterReceiveChannelRtpStatisticsCallback,
11685bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org                    (int, webrtc::StreamDataCountersCallback*));
11695bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB(RegisterSendBitrateObserver,
11705bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org                    (int, webrtc::BitrateStatisticsObserver*));
11715bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB(DeregisterSendBitrateObserver,
11725bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org                    (int, webrtc::BitrateStatisticsObserver*));
11735bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB(RegisterSendFrameCountObserver,
11745bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org                    (int, webrtc::FrameCountObserver*));
11755bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org  WEBRTC_STUB(DeregisterSendFrameCountObserver,
11765bc25c41fc7880545052770dbcfe67f233c9b0c0sergeyu@chromium.org                    (int, webrtc::FrameCountObserver*));
117728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
117828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(StartRTPDump, (const int, const char*, webrtc::RTPDirections));
117928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(StopRTPDump, (const int, webrtc::RTPDirections));
118028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(RegisterRTPObserver, (const int, webrtc::ViERTPObserver&));
118128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(DeregisterRTPObserver, (const int));
118228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(RegisterRTCPObserver, (const int, webrtc::ViERTCPObserver&));
118328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(DeregisterRTCPObserver, (const int));
118428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
118528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // webrtc::ViEImageProcess
118628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(RegisterCaptureEffectFilter, (const int,
118728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      webrtc::ViEEffectFilter&));
118828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(DeregisterCaptureEffectFilter, (const int));
118928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(RegisterSendEffectFilter, (const int,
119028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      webrtc::ViEEffectFilter&));
119128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(DeregisterSendEffectFilter, (const int));
119228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(RegisterRenderEffectFilter, (const int,
119328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      webrtc::ViEEffectFilter&));
119428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(DeregisterRenderEffectFilter, (const int));
119528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(EnableDeflickering, (const int, const bool));
119628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(EnableDenoising, (const int capture_id, const bool denoising)) {
119728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CAPTURER(capture_id);
119828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    capturers_[capture_id]->set_denoising(denoising);
119928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
120028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
120128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_STUB(EnableColorEnhancement, (const int, const bool));
120297077a3ab27259164eb121034b6e0ebe9ba592dfwu@webrtc.org  WEBRTC_VOID_STUB(RegisterPreEncodeCallback,
120397077a3ab27259164eb121034b6e0ebe9ba592dfwu@webrtc.org                   (int, webrtc::I420FrameCallback*));
120497077a3ab27259164eb121034b6e0ebe9ba592dfwu@webrtc.org  WEBRTC_VOID_STUB(DeRegisterPreEncodeCallback, (int));
120597077a3ab27259164eb121034b6e0ebe9ba592dfwu@webrtc.org  WEBRTC_VOID_STUB(RegisterPreRenderCallback,
120697077a3ab27259164eb121034b6e0ebe9ba592dfwu@webrtc.org                   (int, webrtc::I420FrameCallback*));
120797077a3ab27259164eb121034b6e0ebe9ba592dfwu@webrtc.org  WEBRTC_VOID_STUB(DeRegisterPreRenderCallback, (int));
120828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  // webrtc::ViEExternalCodec
120928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(RegisterExternalSendCodec,
121028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      (const int channel, const unsigned char pl_type, webrtc::VideoEncoder*,
121128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org          bool)) {
121228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
121328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->ext_encoder_pl_types_.insert(pl_type);
121428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
121528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
121628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(DeRegisterExternalSendCodec,
121728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      (const int channel, const unsigned char pl_type)) {
121828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
121928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->ext_encoder_pl_types_.erase(pl_type);
122028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
122128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
122228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(RegisterExternalReceiveCodec,
122328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      (const int channel, const unsigned int pl_type, webrtc::VideoDecoder*,
122428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org       bool, int)) {
122528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
122628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->ext_decoder_pl_types_.insert(pl_type);
122728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
122828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
122928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  WEBRTC_FUNC(DeRegisterExternalReceiveCodec,
123028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org      (const int channel, const unsigned char pl_type)) {
123128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    WEBRTC_CHECK_CHANNEL(channel);
123228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    channels_[channel]->ext_decoder_pl_types_.erase(pl_type);
123328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return 0;
123428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
123528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
123628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org private:
123728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool IsChannelId(int id) const {
123828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return (id >= kViEChannelIdBase && id <= kViEChannelIdMax);
123928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
124028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool IsCapturerId(int id) const {
124128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    return (id >= kViECaptureIdBase && id <= kViECaptureIdMax);
124228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  }
124328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
124428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool inited_;
124528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int last_channel_;
124628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  std::map<int, Channel*> channels_;
124728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool fail_create_channel_;
124828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int last_capturer_;
124928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  std::map<int, Capturer*> capturers_;
125028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  bool fail_alloc_capturer_;
125128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  const cricket::VideoCodec* const* codecs_;
125228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int num_codecs_;
125328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  int num_set_send_codecs_;  // how many times we call SetSendCodec().
125428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org};
125528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
125628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org}  // namespace cricket
125728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
125828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#endif  // TALK_MEDIA_WEBRTC_FAKEWEBRTCVIDEOENGINE_H_
1259