本文整理汇总了C++中DOMMediaStream::GetHintContents方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMMediaStream::GetHintContents方法的具体用法?C++ DOMMediaStream::GetHintContents怎么用?C++ DOMMediaStream::GetHintContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMMediaStream
的用法示例。
在下文中一共展示了DOMMediaStream::GetHintContents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
nsresult
PeerConnectionMedia::AddStream(nsIDOMMediaStream* aMediaStream, uint32_t *stream_id)
{
if (!aMediaStream) {
CSFLogError(logTag, "%s - aMediaStream is NULL", __FUNCTION__);
return NS_ERROR_FAILURE;
}
DOMMediaStream* stream = static_cast<DOMMediaStream*>(aMediaStream);
CSFLogDebug(logTag, "%s: MediaStream: %p",
__FUNCTION__, aMediaStream);
// Adding tracks here based on nsDOMMediaStream expectation settings
uint32_t hints = stream->GetHintContents();
#ifdef MOZILLA_INTERNAL_API
if (!Preferences::GetBool("media.peerconnection.video.enabled", true)) {
hints &= ~(DOMMediaStream::HINT_CONTENTS_VIDEO);
}
#endif
if (!(hints & (DOMMediaStream::HINT_CONTENTS_AUDIO |
DOMMediaStream::HINT_CONTENTS_VIDEO))) {
CSFLogDebug(logTag, "Empty Stream !!");
return NS_OK;
}
// Now see if we already have a stream of this type, since we only
// allow one of each.
// TODO([email protected]): remove this when multiple of each stream
// is allowed
mozilla::MutexAutoLock lock(mLocalSourceStreamsLock);
for (uint32_t u = 0; u < mLocalSourceStreams.Length(); u++) {
nsRefPtr<LocalSourceStreamInfo> localSourceStream = mLocalSourceStreams[u];
if (localSourceStream->GetMediaStream()->GetHintContents() & hints) {
CSFLogError(logTag, "Only one stream of any given type allowed");
return NS_ERROR_FAILURE;
}
}
// OK, we're good to add
nsRefPtr<LocalSourceStreamInfo> localSourceStream =
new LocalSourceStreamInfo(stream, this);
*stream_id = mLocalSourceStreams.Length();
if (hints & DOMMediaStream::HINT_CONTENTS_AUDIO) {
localSourceStream->ExpectAudio(TRACK_AUDIO);
}
if (hints & DOMMediaStream::HINT_CONTENTS_VIDEO) {
localSourceStream->ExpectVideo(TRACK_VIDEO);
}
mLocalSourceStreams.AppendElement(localSourceStream);
return NS_OK;
}
示例2:
NS_IMETHODIMP
PeerConnectionImpl::RemoveStream(nsIDOMMediaStream* aMediaStream) {
PC_AUTO_ENTER_API_CALL(true);
uint32_t stream_id;
nsresult res = mMedia->RemoveStream(aMediaStream, &stream_id);
if (NS_FAILED(res))
return res;
DOMMediaStream* stream = static_cast<DOMMediaStream*>(aMediaStream);
uint32_t hints = stream->GetHintContents();
if (hints & DOMMediaStream::HINT_CONTENTS_AUDIO) {
mCall->removeStream(stream_id, 0, AUDIO);
}
if (hints & DOMMediaStream::HINT_CONTENTS_VIDEO) {
mCall->removeStream(stream_id, 1, VIDEO);
}
return NS_OK;
}