Break out glue for old->new Transport.
Reduces multiple inheritance and code duplication. BUG= R=mflodman@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2239004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4774 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
fe84fda488
commit
e75a1bf45f
@ -7,8 +7,8 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef WEBRTC_VIDEO_ENGINE_CALL_IMPL_H_
|
||||
#define WEBRTC_VIDEO_ENGINE_CALL_IMPL_H_
|
||||
#ifndef WEBRTC_VIDEO_ENGINE_INTERNAL_CALL_H_
|
||||
#define WEBRTC_VIDEO_ENGINE_INTERNAL_CALL_H_
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
36
webrtc/video_engine/internal/transport_adapter.cc
Normal file
36
webrtc/video_engine/internal/transport_adapter.cc
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/video_engine/internal/transport_adapter.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace internal {
|
||||
|
||||
TransportAdapter::TransportAdapter(newapi::Transport* transport)
|
||||
: transport_(transport) {}
|
||||
|
||||
int TransportAdapter::SendPacket(int /*channel*/,
|
||||
const void* packet,
|
||||
int length) {
|
||||
bool success = transport_->SendRTP(static_cast<const uint8_t*>(packet),
|
||||
static_cast<size_t>(length));
|
||||
return success ? length : -1;
|
||||
}
|
||||
|
||||
int TransportAdapter::SendRTCPPacket(int /*channel*/,
|
||||
const void* packet,
|
||||
int length) {
|
||||
bool success = transport_->SendRTCP(static_cast<const uint8_t*>(packet),
|
||||
static_cast<size_t>(length));
|
||||
return success ? length : -1;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace webrtc
|
34
webrtc/video_engine/internal/transport_adapter.h
Normal file
34
webrtc/video_engine/internal/transport_adapter.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef WEBRTC_VIDEO_ENGINE_INTERNAL_TRANSPORT_ADAPTER_H_
|
||||
#define WEBRTC_VIDEO_ENGINE_INTERNAL_TRANSPORT_ADAPTER_H_
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/video_engine/new_include/transport.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace internal {
|
||||
|
||||
class TransportAdapter : public webrtc::Transport {
|
||||
public:
|
||||
explicit TransportAdapter(newapi::Transport* transport);
|
||||
|
||||
virtual int SendPacket(int /*channel*/, const void* packet, int length)
|
||||
OVERRIDE;
|
||||
virtual int SendRTCPPacket(int /*channel*/, const void* packet, int length)
|
||||
OVERRIDE;
|
||||
|
||||
private:
|
||||
newapi::Transport *transport_;
|
||||
};
|
||||
} // namespace internal
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_VIDEO_ENGINE_INTERNAL_TRANSPORT_ADAPTER_H_
|
@ -30,7 +30,7 @@ namespace internal {
|
||||
VideoReceiveStream::VideoReceiveStream(webrtc::VideoEngine* video_engine,
|
||||
const VideoReceiveStream::Config& config,
|
||||
newapi::Transport* transport)
|
||||
: transport_(transport), config_(config), channel_(-1) {
|
||||
: transport_adapter_(transport), config_(config), channel_(-1) {
|
||||
video_engine_base_ = ViEBase::GetInterface(video_engine);
|
||||
// TODO(mflodman): Use the other CreateChannel method.
|
||||
video_engine_base_->CreateChannel(channel_);
|
||||
@ -48,7 +48,7 @@ VideoReceiveStream::VideoReceiveStream(webrtc::VideoEngine* video_engine,
|
||||
network_ = ViENetwork::GetInterface(video_engine);
|
||||
assert(network_ != NULL);
|
||||
|
||||
network_->RegisterSendTransport(channel_, *this);
|
||||
network_->RegisterSendTransport(channel_, transport_adapter_);
|
||||
|
||||
codec_ = ViECodec::GetInterface(video_engine);
|
||||
|
||||
@ -177,22 +177,5 @@ int VideoReceiveStream::DeliverFrame(uint8_t* frame,
|
||||
|
||||
bool VideoReceiveStream::IsTextureSupported() { return false; }
|
||||
|
||||
int VideoReceiveStream::SendPacket(int /*channel*/,
|
||||
const void* packet,
|
||||
int length) {
|
||||
assert(length >= 0);
|
||||
bool success = transport_->SendRTP(static_cast<const uint8_t*>(packet),
|
||||
static_cast<size_t>(length));
|
||||
return success ? 0 : -1;
|
||||
}
|
||||
|
||||
int VideoReceiveStream::SendRTCPPacket(int /*channel*/,
|
||||
const void* packet,
|
||||
int length) {
|
||||
assert(length >= 0);
|
||||
bool success = transport_->SendRTCP(static_cast<const uint8_t*>(packet),
|
||||
static_cast<size_t>(length));
|
||||
return success ? 0 : -1;
|
||||
}
|
||||
} // internal
|
||||
} // webrtc
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
#include "webrtc/video_engine/include/vie_render.h"
|
||||
#include "webrtc/video_engine/internal/transport_adapter.h"
|
||||
#include "webrtc/video_engine/new_include/video_receive_stream.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -31,8 +32,7 @@ class ViERTP_RTCP;
|
||||
namespace internal {
|
||||
|
||||
class VideoReceiveStream : public webrtc::VideoReceiveStream,
|
||||
public webrtc::ExternalRenderer,
|
||||
public webrtc::Transport {
|
||||
public webrtc::ExternalRenderer {
|
||||
public:
|
||||
VideoReceiveStream(webrtc::VideoEngine* video_engine,
|
||||
const VideoReceiveStream::Config& config,
|
||||
@ -51,17 +51,12 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream,
|
||||
|
||||
virtual bool IsTextureSupported() OVERRIDE;
|
||||
|
||||
virtual int SendPacket(int /*channel*/, const void* packet, int length)
|
||||
OVERRIDE;
|
||||
virtual int SendRTCPPacket(int /*channel*/, const void* packet, int length)
|
||||
OVERRIDE;
|
||||
|
||||
public:
|
||||
virtual bool DeliverRtcp(const uint8_t* packet, size_t length);
|
||||
virtual bool DeliverRtp(const uint8_t* packet, size_t length);
|
||||
|
||||
private:
|
||||
newapi::Transport* transport_;
|
||||
TransportAdapter transport_adapter_;
|
||||
VideoReceiveStream::Config config_;
|
||||
Clock* clock_;
|
||||
|
||||
|
@ -80,7 +80,7 @@ VideoSendStream::VideoSendStream(newapi::Transport* transport,
|
||||
bool overuse_detection,
|
||||
webrtc::VideoEngine* video_engine,
|
||||
const VideoSendStream::Config& config)
|
||||
: transport_(transport), config_(config), external_codec_(NULL) {
|
||||
: transport_adapter_(transport), config_(config), external_codec_(NULL) {
|
||||
|
||||
if (config_.codec.numberOfSimulcastStreams > 0) {
|
||||
assert(config_.rtp.ssrcs.size() == config_.codec.numberOfSimulcastStreams);
|
||||
@ -146,7 +146,7 @@ VideoSendStream::VideoSendStream(newapi::Transport* transport,
|
||||
network_ = ViENetwork::GetInterface(video_engine);
|
||||
assert(network_ != NULL);
|
||||
|
||||
network_->RegisterSendTransport(channel_, *this);
|
||||
network_->RegisterSendTransport(channel_, transport_adapter_);
|
||||
|
||||
if (config.encoder) {
|
||||
external_codec_ = ViEExternalCodec::GetInterface(video_engine);
|
||||
@ -250,26 +250,6 @@ void VideoSendStream::GetSendCodec(VideoCodec* send_codec) {
|
||||
*send_codec = config_.codec;
|
||||
}
|
||||
|
||||
int VideoSendStream::SendPacket(int /*channel*/,
|
||||
const void* packet,
|
||||
int length) {
|
||||
// TODO(pbos): Lock these methods and the destructor so it can't be processing
|
||||
// a packet when the destructor has been called.
|
||||
assert(length >= 0);
|
||||
bool success = transport_->SendRTP(static_cast<const uint8_t*>(packet),
|
||||
static_cast<size_t>(length));
|
||||
return success ? length : -1;
|
||||
}
|
||||
|
||||
int VideoSendStream::SendRTCPPacket(int /*channel*/,
|
||||
const void* packet,
|
||||
int length) {
|
||||
assert(length >= 0);
|
||||
bool success = transport_->SendRTCP(static_cast<const uint8_t*>(packet),
|
||||
static_cast<size_t>(length));
|
||||
return success ? length : -1;
|
||||
}
|
||||
|
||||
bool VideoSendStream::DeliverRtcp(const uint8_t* packet, size_t length) {
|
||||
return network_->ReceivedRTCPPacket(
|
||||
channel_, packet, static_cast<int>(length)) == 0;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/video_engine/internal/transport_adapter.h"
|
||||
#include "webrtc/video_engine/new_include/video_receive_stream.h"
|
||||
#include "webrtc/video_engine/new_include/video_send_stream.h"
|
||||
|
||||
@ -33,8 +34,7 @@ namespace internal {
|
||||
class ResolutionAdaptor;
|
||||
|
||||
class VideoSendStream : public webrtc::VideoSendStream,
|
||||
public VideoSendStreamInput,
|
||||
public webrtc::Transport {
|
||||
public VideoSendStreamInput {
|
||||
public:
|
||||
VideoSendStream(newapi::Transport* transport,
|
||||
bool overuse_detection,
|
||||
@ -58,17 +58,11 @@ class VideoSendStream : public webrtc::VideoSendStream,
|
||||
|
||||
virtual void GetSendCodec(VideoCodec* send_codec) OVERRIDE;
|
||||
|
||||
virtual int SendPacket(int /*channel*/, const void* packet, int length)
|
||||
OVERRIDE;
|
||||
|
||||
virtual int SendRTCPPacket(int /*channel*/, const void* packet, int length)
|
||||
OVERRIDE;
|
||||
|
||||
public:
|
||||
bool DeliverRtcp(const uint8_t* packet, size_t length);
|
||||
|
||||
private:
|
||||
newapi::Transport* transport_;
|
||||
TransportAdapter transport_adapter_;
|
||||
VideoSendStream::Config config_;
|
||||
|
||||
ViEBase* video_engine_base_;
|
||||
|
@ -117,6 +117,8 @@
|
||||
# New VideoEngine API
|
||||
'internal/call.cc',
|
||||
'internal/call.h',
|
||||
'internal/transport_adapter.cc',
|
||||
'internal/transport_adapter.h',
|
||||
'internal/video_receive_stream.cc',
|
||||
'internal/video_receive_stream.h',
|
||||
'internal/video_send_stream.cc',
|
||||
|
Loading…
Reference in New Issue
Block a user