Bug 792188: Add hints to MediaStreams to help with generating signaling r=jesup

This commit is contained in:
Anant Narayanan 2012-10-07 01:34:30 -04:00
parent 2ae69bfc6d
commit 92ad319945
2 changed files with 32 additions and 9 deletions

View File

@ -26,7 +26,7 @@ class nsDOMMediaStream : public nsIDOMMediaStream
typedef mozilla::MediaStream MediaStream;
public:
nsDOMMediaStream() : mStream(nullptr) {}
nsDOMMediaStream() : mStream(nullptr), mHintContents(0) {}
virtual ~nsDOMMediaStream();
NS_DECL_CYCLE_COLLECTION_CLASS(nsDOMMediaStream)
@ -53,7 +53,16 @@ public:
/**
* Create an nsDOMMediaStream whose underlying stream is a SourceMediaStream.
*/
static already_AddRefed<nsDOMMediaStream> CreateInputStream();
static already_AddRefed<nsDOMMediaStream> CreateInputStream(uint32_t aHintContents);
// Hints to tell the SDP generator about whether this
// MediaStream probably has audio and/or video
enum {
HINT_CONTENTS_AUDIO = 0x00000001U,
HINT_CONTENTS_VIDEO = 0x00000002U
};
uint32_t GetHintContents() const { return mHintContents; }
void SetHintContents(uint32_t aHintContents) { mHintContents = aHintContents; }
/**
* Create an nsDOMMediaStream whose underlying stream is a TrackUnionStream.
@ -67,6 +76,10 @@ protected:
// Principal identifying who may access the contents of this stream.
// If null, this stream can be used by anyone because it has no content yet.
nsCOMPtr<nsIPrincipal> mPrincipal;
// tells the SDP generator about whether this
// MediaStream probably has audio and/or video
uint32_t mHintContents;
};
#endif /* NSDOMMEDIASTREAM_H_ */

View File

@ -26,6 +26,13 @@
namespace mozilla {
// We only support 1 audio and 1 video track for now.
enum {
kVideoTrack = 1,
kAudioTrack = 2
};
/**
* Send an error back to content. The error is the form a string.
* Do this only on the main thread. The success callback is also passed here
@ -219,7 +226,16 @@ public:
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
// Create a media stream.
nsCOMPtr<nsDOMMediaStream> stream = nsDOMMediaStream::CreateInputStream();
nsCOMPtr<nsDOMMediaStream> stream;
if (mTrackID == kVideoTrack) {
stream = nsDOMMediaStream::CreateInputStream(
nsDOMMediaStream::HINT_CONTENTS_VIDEO
);
} else {
stream = nsDOMMediaStream::CreateInputStream(
nsDOMMediaStream::HINT_CONTENTS_AUDIO
);
}
nsPIDOMWindow *window = static_cast<nsPIDOMWindow*>
(nsGlobalWindow::GetInnerWindowWithId(mWindowID));
@ -329,12 +345,6 @@ public:
}
}
// We only support 1 audio and 1 video track for now.
enum {
kVideoTrack = 1,
kAudioTrack = 2
};
NS_IMETHOD
Run()
{