Move ViewRequest and MediaStreams to streamparams.h, and remove dependency on mediasessionclient.h and mediamessages.h. This is part of the effort to remove Jingle-specific code from WebRTC and into its own repository.

R=juberti@webrtc.org, pbos@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/36519004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7921 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pthatcher@webrtc.org 2014-12-16 21:09:08 +00:00
parent a32487f97b
commit e2b7585bc2
8 changed files with 130 additions and 130 deletions

View File

@ -43,7 +43,6 @@
#include "webrtc/p2p/base/constants.h"
#include "webrtc/p2p/base/port.h"
#include "talk/session/media/mediasession.h"
#include "talk/session/media/mediasessionclient.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/messagedigest.h"

View File

@ -30,12 +30,71 @@
#include <list>
#include <sstream>
namespace {
// NOTE: There is no check here for duplicate streams, so check before
// adding.
void AddStream(std::vector<cricket::StreamParams>* streams,
const cricket::StreamParams& stream) {
streams->push_back(stream);
}
}
namespace cricket {
const char kFecSsrcGroupSemantics[] = "FEC";
const char kFidSsrcGroupSemantics[] = "FID";
const char kSimSsrcGroupSemantics[] = "SIM";
bool MediaStreams::GetAudioStream(
const StreamSelector& selector, StreamParams* stream) {
return GetStream(audio_, selector, stream);
}
bool MediaStreams::GetVideoStream(
const StreamSelector& selector, StreamParams* stream) {
return GetStream(video_, selector, stream);
}
bool MediaStreams::GetDataStream(
const StreamSelector& selector, StreamParams* stream) {
return GetStream(data_, selector, stream);
}
void MediaStreams::CopyFrom(const MediaStreams& streams) {
audio_ = streams.audio_;
video_ = streams.video_;
data_ = streams.data_;
}
void MediaStreams::AddAudioStream(const StreamParams& stream) {
AddStream(&audio_, stream);
}
void MediaStreams::AddVideoStream(const StreamParams& stream) {
AddStream(&video_, stream);
}
void MediaStreams::AddDataStream(const StreamParams& stream) {
AddStream(&data_, stream);
}
bool MediaStreams::RemoveAudioStream(
const StreamSelector& selector) {
return RemoveStream(&audio_, selector);
}
bool MediaStreams::RemoveVideoStream(
const StreamSelector& selector) {
return RemoveStream(&video_, selector);
}
bool MediaStreams::RemoveDataStream(
const StreamSelector& selector) {
return RemoveStream(&data_, selector);
}
static std::string SsrcsToString(const std::vector<uint32>& ssrcs) {
std::ostringstream ost;
ost << "ssrcs:[";

View File

@ -203,6 +203,77 @@ struct StreamSelector {
typedef std::vector<StreamParams> StreamParamsVec;
// A collection of audio and video and data streams. Most of the
// methods are merely for convenience. Many of these methods are keyed
// by ssrc, which is the source identifier in the RTP spec
// (http://tools.ietf.org/html/rfc3550).
// TODO(pthatcher): Add basic unit test for these.
// See https://code.google.com/p/webrtc/issues/detail?id=4107
struct MediaStreams {
public:
MediaStreams() {}
void CopyFrom(const MediaStreams& sources);
bool empty() const {
return audio_.empty() && video_.empty() && data_.empty();
}
std::vector<StreamParams>* mutable_audio() { return &audio_; }
std::vector<StreamParams>* mutable_video() { return &video_; }
std::vector<StreamParams>* mutable_data() { return &data_; }
const std::vector<StreamParams>& audio() const { return audio_; }
const std::vector<StreamParams>& video() const { return video_; }
const std::vector<StreamParams>& data() const { return data_; }
// Gets a stream, returning true if found.
bool GetAudioStream(
const StreamSelector& selector, StreamParams* stream);
bool GetVideoStream(
const StreamSelector& selector, StreamParams* stream);
bool GetDataStream(
const StreamSelector& selector, StreamParams* stream);
// Adds a stream.
void AddAudioStream(const StreamParams& stream);
void AddVideoStream(const StreamParams& stream);
void AddDataStream(const StreamParams& stream);
// Removes a stream, returning true if found and removed.
bool RemoveAudioStream(const StreamSelector& selector);
bool RemoveVideoStream(const StreamSelector& selector);
bool RemoveDataStream(const StreamSelector& selector);
private:
std::vector<StreamParams> audio_;
std::vector<StreamParams> video_;
std::vector<StreamParams> data_;
DISALLOW_COPY_AND_ASSIGN(MediaStreams);
};
// A request for a specific format of a specific stream.
struct StaticVideoView {
StaticVideoView(const StreamSelector& selector,
int width, int height, int framerate)
: selector(selector),
width(width),
height(height),
framerate(framerate),
preference(0) {
}
StreamSelector selector;
int width;
int height;
int framerate;
int preference;
};
typedef std::vector<StaticVideoView> StaticVideoViews;
// A request for several streams in various formats.
struct ViewRequest {
StaticVideoViews static_video_views;
};
// Finds the stream in streams. Returns true if found.
bool GetStream(const StreamParamsVec& streams,
const StreamSelector& selector,

View File

@ -31,7 +31,6 @@
#include "talk/media/base/rtputils.h"
#include "webrtc/p2p/base/transportchannel.h"
#include "talk/session/media/channelmanager.h"
#include "talk/session/media/mediamessages.h"
#include "talk/session/media/typingmonitor.h"
#include "webrtc/base/bind.h"
#include "webrtc/base/buffer.h"

View File

@ -33,9 +33,7 @@
#include "talk/media/base/testutils.h"
#include "webrtc/p2p/base/fakesession.h"
#include "talk/session/media/channel.h"
#include "talk/session/media/mediamessages.h"
#include "talk/session/media/mediarecorder.h"
#include "talk/session/media/mediasessionclient.h"
#include "talk/session/media/typingmonitor.h"
#include "webrtc/base/fileutils.h"
#include "webrtc/base/gunit.h"

View File

@ -29,7 +29,6 @@
#include "talk/media/base/streamparams.h"
#include "talk/session/media/audiomonitor.h"
#include "talk/session/media/mediamessages.h"
#include "webrtc/base/logging.h"
namespace cricket {

View File

@ -42,12 +42,6 @@ namespace cricket {
namespace {
// NOTE: There is no check here for duplicate streams, so check before
// adding.
void AddStream(std::vector<StreamParams>* streams, const StreamParams& stream) {
streams->push_back(stream);
}
bool ParseSsrc(const std::string& string, uint32* ssrc) {
return rtc::FromString(string, ssrc);
}
@ -90,54 +84,6 @@ buzz::XmlElement* CreateStaticVideoViewElem(const std::string& content_name,
} // namespace
bool MediaStreams::GetAudioStream(
const StreamSelector& selector, StreamParams* stream) {
return GetStream(audio_, selector, stream);
}
bool MediaStreams::GetVideoStream(
const StreamSelector& selector, StreamParams* stream) {
return GetStream(video_, selector, stream);
}
bool MediaStreams::GetDataStream(
const StreamSelector& selector, StreamParams* stream) {
return GetStream(data_, selector, stream);
}
void MediaStreams::CopyFrom(const MediaStreams& streams) {
audio_ = streams.audio_;
video_ = streams.video_;
data_ = streams.data_;
}
void MediaStreams::AddAudioStream(const StreamParams& stream) {
AddStream(&audio_, stream);
}
void MediaStreams::AddVideoStream(const StreamParams& stream) {
AddStream(&video_, stream);
}
void MediaStreams::AddDataStream(const StreamParams& stream) {
AddStream(&data_, stream);
}
bool MediaStreams::RemoveAudioStream(
const StreamSelector& selector) {
return RemoveStream(&audio_, selector);
}
bool MediaStreams::RemoveVideoStream(
const StreamSelector& selector) {
return RemoveStream(&video_, selector);
}
bool MediaStreams::RemoveDataStream(
const StreamSelector& selector) {
return RemoveStream(&data_, selector);
}
bool IsJingleViewRequest(const buzz::XmlElement* action_elem) {
return action_elem->FirstNamed(QN_JINGLE_DRAFT_VIEW) != NULL;
}

View File

@ -47,77 +47,6 @@
namespace cricket {
// A collection of audio and video and data streams. Most of the
// methods are merely for convenience. Many of these methods are keyed
// by ssrc, which is the source identifier in the RTP spec
// (http://tools.ietf.org/html/rfc3550).
struct MediaStreams {
public:
MediaStreams() {}
void CopyFrom(const MediaStreams& sources);
bool empty() const {
return audio_.empty() && video_.empty() && data_.empty();
}
std::vector<StreamParams>* mutable_audio() { return &audio_; }
std::vector<StreamParams>* mutable_video() { return &video_; }
std::vector<StreamParams>* mutable_data() { return &data_; }
const std::vector<StreamParams>& audio() const { return audio_; }
const std::vector<StreamParams>& video() const { return video_; }
const std::vector<StreamParams>& data() const { return data_; }
// Gets a stream, returning true if found.
bool GetAudioStream(
const StreamSelector& selector, StreamParams* stream);
bool GetVideoStream(
const StreamSelector& selector, StreamParams* stream);
bool GetDataStream(
const StreamSelector& selector, StreamParams* stream);
// Adds a stream.
void AddAudioStream(const StreamParams& stream);
void AddVideoStream(const StreamParams& stream);
void AddDataStream(const StreamParams& stream);
// Removes a stream, returning true if found and removed.
bool RemoveAudioStream(const StreamSelector& selector);
bool RemoveVideoStream(const StreamSelector& selector);
bool RemoveDataStream(const StreamSelector& selector);
private:
std::vector<StreamParams> audio_;
std::vector<StreamParams> video_;
std::vector<StreamParams> data_;
DISALLOW_COPY_AND_ASSIGN(MediaStreams);
};
// In a <view> message, there are a number of views specified. This
// represents one such view. We currently only support "static"
// views.
struct StaticVideoView {
StaticVideoView(const StreamSelector& selector,
int width, int height, int framerate)
: selector(selector),
width(width),
height(height),
framerate(framerate),
preference(0) {
}
StreamSelector selector;
int width;
int height;
int framerate;
int preference;
};
typedef std::vector<StaticVideoView> StaticVideoViews;
// Represents a whole view request message, which contains many views.
struct ViewRequest {
StaticVideoViews static_video_views;
};
// If the parent element (usually <jingle>) is a jingle view.
bool IsJingleViewRequest(const buzz::XmlElement* action_elem);