}
}
+// Filters the data codecs for the data channel type.
+void FilterDataCodecs(std::vector<DataCodec>* codecs, bool sctp) {
+ // Filter RTP codec for SCTP and vice versa.
+ int codec_id = sctp ? kGoogleRtpDataCodecId : kGoogleSctpDataCodecId;
+ for (std::vector<DataCodec>::iterator iter = codecs->begin();
+ iter != codecs->end();) {
+ if (iter->id == codec_id) {
+ iter = codecs->erase(iter);
+ } else {
+ ++iter;
+ }
+ }
+}
+
template <typename IdStruct>
class UsedIds {
public:
}
private:
- // Min and Max local identifier as specified by RFC5285.
+ // Min and Max local identifier for one-byte header extensions, per RFC5285.
static const int kLocalIdMin = 1;
- static const int kLocalIdMax = 255;
+ static const int kLocalIdMax = 14;
};
static bool IsSctp(const MediaContentDescription* desc) {
static bool CreateMediaContentOffer(
const MediaSessionOptions& options,
const std::vector<C>& codecs,
- const SecureMediaPolicy& secure_policy,
+ const SecurePolicy& secure_policy,
const CryptoParamsVec* current_cryptos,
const std::vector<std::string>& crypto_suites,
const RtpHeaderExtensions& rtp_extensions,
offer->AddCodecs(codecs);
offer->SortCodecs();
- offer->set_crypto_required(secure_policy == SEC_REQUIRED);
+ if (secure_policy == SEC_REQUIRED) {
+ offer->set_crypto_required(CT_SDES);
+ }
offer->set_rtcp_mux(options.rtcp_mux_enabled);
offer->set_multistream(options.is_muc);
offer->set_rtp_header_extensions(rtp_extensions);
}
#endif
- if (offer->crypto_required() && offer->cryptos().empty()) {
+ if (offer->crypto_required() == CT_SDES && offer->cryptos().empty()) {
return false;
}
return true;
// We assume that all URIs are given in a canonical format.
if (it->uri == ext_to_match.uri) {
if (found_extension != NULL) {
- *found_extension= *it;
+ *found_extension = *it;
}
return true;
}
static void FindAndSetRtpHdrExtUsed(
const RtpHeaderExtensions& reference_extensions,
RtpHeaderExtensions* offered_extensions,
+ const RtpHeaderExtensions& other_extensions,
UsedRtpHeaderExtensionIds* used_extensions) {
for (RtpHeaderExtensions::const_iterator it = reference_extensions.begin();
it != reference_extensions.end(); ++it) {
if (!FindByUri(*offered_extensions, *it, NULL)) {
- RtpHeaderExtension ext = *it;
- used_extensions->FindAndSetIdUsed(&ext);
+ RtpHeaderExtension ext;
+ if (!FindByUri(other_extensions, *it, &ext)) {
+ ext = *it;
+ used_extensions->FindAndSetIdUsed(&ext);
+ }
offered_extensions->push_back(ext);
}
}
const MediaContentDescriptionImpl<C>* offer,
const MediaSessionOptions& options,
const std::vector<C>& local_codecs,
- const SecureMediaPolicy& sdes_policy,
+ const SecurePolicy& sdes_policy,
const CryptoParamsVec* current_cryptos,
const RtpHeaderExtensions& local_rtp_extenstions,
StreamParamsVec* current_streams,
}
if (answer->cryptos().empty() &&
- (offer->crypto_required() || sdes_policy == SEC_REQUIRED)) {
+ (offer->crypto_required() == CT_SDES || sdes_policy == SEC_REQUIRED)) {
return false;
}
return current_tdesc->secure();
}
+std::string MediaTypeToString(MediaType type) {
+ std::string type_str;
+ switch (type) {
+ case MEDIA_TYPE_AUDIO:
+ type_str = "audio";
+ break;
+ case MEDIA_TYPE_VIDEO:
+ type_str = "video";
+ break;
+ case MEDIA_TYPE_DATA:
+ type_str = "data";
+ break;
+ default:
+ ASSERT(false);
+ break;
+ }
+ return type_str;
+}
+
void MediaSessionOptions::AddStream(MediaType type,
const std::string& id,
const std::string& sync_label) {
scoped_ptr<DataContentDescription> data(new DataContentDescription());
bool is_sctp = (options.data_channel_type == DCT_SCTP);
+ FilterDataCodecs(&data_codecs, is_sctp);
+
cricket::SecurePolicy sdes_policy =
IsDtlsActive(CN_DATA, current_description) ?
cricket::SEC_DISABLED : secure();
if (!data_transport) {
return NULL;
}
+ bool is_sctp = (options.data_channel_type == DCT_SCTP);
+ std::vector<DataCodec> data_codecs(data_codecs_);
+ FilterDataCodecs(&data_codecs, is_sctp);
+
scoped_ptr<DataContentDescription> data_answer(
new DataContentDescription());
// Do not require or create SDES cryptos if DTLS is used.
const SessionDescription* current_description,
RtpHeaderExtensions* audio_extensions,
RtpHeaderExtensions* video_extensions) const {
+ // All header extensions allocated from the same range to avoid potential
+ // issues when using BUNDLE.
UsedRtpHeaderExtensionIds used_ids;
audio_extensions->clear();
video_extensions->clear();
// Add our default RTP header extensions that are not in
// |current_description|.
FindAndSetRtpHdrExtUsed(audio_rtp_header_extensions(), audio_extensions,
- &used_ids);
+ *video_extensions, &used_ids);
FindAndSetRtpHdrExtUsed(video_rtp_header_extensions(), video_extensions,
- &used_ids);
+ *audio_extensions, &used_ids);
}
bool MediaSessionDescriptionFactory::AddTransportOffer(