Make ContentInfo/ContentDescription slightly more ergonomic

This makes the following changes:
- Replaces ContentDescription with its only subclass,
    MediaContentDescription
- Adds helpers to cast a MediaContentDescription to its
    audio, video, and data subclasses.
- Changes ContentInfo.type to a new enum, MediaProtocolType.

Bug: webrtc:8620
Change-Id: I5eb0811cb16a51b0b9d73ecc4fe8edc7037f1aed
Reviewed-on: https://webrtc-review.googlesource.com/35100
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Peter Thatcher <pthatcher@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21401}
This commit is contained in:
Steve Anton
2017-12-20 16:34:00 -08:00
committed by Commit Bot
parent f8409521d9
commit 5adfafdbf6
11 changed files with 150 additions and 111 deletions

View File

@ -1870,7 +1870,7 @@ bool MediaSessionDescriptionFactory::AddAudioContentForOffer(
audio->set_direction(media_description_options.direction);
desc->AddContent(media_description_options.mid, NS_JINGLE_RTP,
desc->AddContent(media_description_options.mid, MediaProtocolType::kRtp,
media_description_options.stopped, audio.release());
if (!AddTransportOffer(media_description_options.mid,
media_description_options.transport_options,
@ -1940,7 +1940,7 @@ bool MediaSessionDescriptionFactory::AddVideoContentForOffer(
video->set_direction(media_description_options.direction);
desc->AddContent(media_description_options.mid, NS_JINGLE_RTP,
desc->AddContent(media_description_options.mid, MediaProtocolType::kRtp,
media_description_options.stopped, video.release());
if (!AddTransportOffer(media_description_options.mid,
media_description_options.transport_options,
@ -2002,12 +2002,12 @@ bool MediaSessionDescriptionFactory::AddDataContentForOffer(
}
if (is_sctp) {
desc->AddContent(media_description_options.mid, NS_JINGLE_DRAFT_SCTP,
desc->AddContent(media_description_options.mid, MediaProtocolType::kSctp,
data.release());
} else {
data->set_bandwidth(kDataMaxBandwidth);
SetMediaProtocol(secure_transport, data.get());
desc->AddContent(media_description_options.mid, NS_JINGLE_RTP,
desc->AddContent(media_description_options.mid, MediaProtocolType::kRtp,
media_description_options.stopped, data.release());
}
if (!AddTransportOffer(media_description_options.mid,
@ -2301,9 +2301,8 @@ void MediaSessionDescriptionFactory::ComputeAudioCodecsIntersectionAndUnion() {
}
bool IsMediaContent(const ContentInfo* content) {
return (content &&
(content->type == NS_JINGLE_RTP ||
content->type == NS_JINGLE_DRAFT_SCTP));
return (content && (content->type == MediaProtocolType::kRtp ||
content->type == MediaProtocolType::kSctp));
}
bool IsAudioContent(const ContentInfo* content) {