summaryrefslogtreecommitdiffstats
path: root/dom/media/mediasink/OutputStreamManager.h
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-06-07 16:04:56 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-06-07 16:04:56 +0200
commitd7beb75aa889967780067ade8219b4a662f22e38 (patch)
tree05714e8825122be0cd5a7d5e185b40bd967ae2a2 /dom/media/mediasink/OutputStreamManager.h
parent271f1ef600c06a74471665a040c9473d9f7a9a36 (diff)
downloadUXP-d7beb75aa889967780067ade8219b4a662f22e38.tar
UXP-d7beb75aa889967780067ade8219b4a662f22e38.tar.gz
UXP-d7beb75aa889967780067ade8219b4a662f22e38.tar.lz
UXP-d7beb75aa889967780067ade8219b4a662f22e38.tar.xz
UXP-d7beb75aa889967780067ade8219b4a662f22e38.zip
Media: harden TrackID handling.
Diffstat (limited to 'dom/media/mediasink/OutputStreamManager.h')
-rw-r--r--dom/media/mediasink/OutputStreamManager.h35
1 files changed, 26 insertions, 9 deletions
diff --git a/dom/media/mediasink/OutputStreamManager.h b/dom/media/mediasink/OutputStreamManager.h
index 7f91a60c1..941a86cf0 100644
--- a/dom/media/mediasink/OutputStreamManager.h
+++ b/dom/media/mediasink/OutputStreamManager.h
@@ -9,6 +9,7 @@
#include "mozilla/RefPtr.h"
#include "nsTArray.h"
+#include "MediaSegment.h"
namespace mozilla {
@@ -21,11 +22,13 @@ class ProcessedMediaStream;
class OutputStreamData {
public:
~OutputStreamData();
- void Init(OutputStreamManager* aOwner, ProcessedMediaStream* aStream);
+ void Init(OutputStreamManager* aOwner,
+ ProcessedMediaStream* aStream,
+ TrackID aNextAvailableTrackID);
- // Connect mStream to the input stream.
+ // Connect the given input stream's audio and video tracks to mStream.
// Return false is mStream is already destroyed, otherwise true.
- bool Connect(MediaStream* aStream);
+ bool Connect(MediaStream* aStream, TrackID aAudioTrackID, TrackID aVideoTrackID);
// Disconnect mStream from its input stream.
// Return false is mStream is already destroyed, otherwise true.
bool Disconnect();
@@ -34,12 +37,16 @@ public:
bool Equals(MediaStream* aStream) const;
// Return the graph mStream belongs to.
MediaStreamGraph* Graph() const;
+ // The next TrackID that will not cause a collision in mStream.
+ TrackID NextAvailableTrackID() const;
private:
OutputStreamManager* mOwner;
RefPtr<ProcessedMediaStream> mStream;
- // mPort connects our mStream to an input stream.
- RefPtr<MediaInputPort> mPort;
+ // mPort connects an input stream to our mStream.
+ nsTArray<RefPtr<MediaInputPort>> mPorts;
+ // For guaranteeing TrackID uniqueness in our mStream.
+ TrackID mNextAvailableTrackID = TRACK_INVALID;
};
class OutputStreamManager {
@@ -47,18 +54,26 @@ class OutputStreamManager {
public:
// Add the output stream to the collection.
- void Add(ProcessedMediaStream* aStream, bool aFinishWhenEnded);
+ void Add(ProcessedMediaStream* aStream,
+ TrackID aNextAvailableTrackID,
+ bool aFinishWhenEnded);
// Remove the output stream from the collection.
void Remove(MediaStream* aStream);
+ // Clear all output streams from the collection.
+ void Clear();
+ // The next TrackID that will not cause a collision in aOutputStream.
+ TrackID NextAvailableTrackIDFor(MediaStream* aOutputStream) const;
// Return true if the collection empty.
bool IsEmpty() const
{
MOZ_ASSERT(NS_IsMainThread());
return mStreams.IsEmpty();
}
- // Connect all output streams in the collection to the input stream.
- void Connect(MediaStream* aStream);
- // Disconnect all output streams from the input stream.
+ // Connect the given input stream's tracks to all output streams.
+ void Connect(MediaStream* aStream,
+ TrackID aAudioTrackID,
+ TrackID aVideoTrackID);
+ // Disconnect the input stream to all output streams.
void Disconnect();
// Return the graph these streams belong to or null if empty.
MediaStreamGraph* Graph() const
@@ -72,6 +87,8 @@ private:
// Keep the input stream so we can connect the output streams that
// are added after Connect().
RefPtr<MediaStream> mInputStream;
+ TrackID mInputAudioTrackID = TRACK_INVALID;
+ TrackID mInputVideoTrackID = TRACK_INVALID;
nsTArray<OutputStreamData> mStreams;
};