Source/WebCore/ChangeLog

 12011-05-31 Tommy Widenflycht <tommyw@google.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Media Stream API: integrate the Track List objects into the existing code.
 6 https://bugs.webkit.org/show_bug.cgi?id=60205
 7
 8 Tests for the Media Stream API will be provided by the bug 56587.
 9
 10 * dom/ExclusiveTrackList.cpp:
 11 (WebCore::ExclusiveTrackList::select):
 12 (WebCore::ExclusiveTrackList::trackFailed):
 13 * dom/ExclusiveTrackList.h:
 14 * dom/GeneratedStream.cpp:
 15 (WebCore::GeneratedStream::create):
 16 (WebCore::GeneratedStream::GeneratedStream):
 17 (WebCore::GeneratedStream::streamEnded):
 18 (WebCore::GeneratedStream::audioTracks):
 19 (WebCore::GeneratedStream::videoTracks):
 20 (WebCore::GeneratedStream::stop):
 21 * dom/GeneratedStream.h:
 22 * dom/GeneratedStream.idl:
 23 * dom/MultipleTrackList.cpp:
 24 (WebCore::MultipleTrackList::trackFailed):
 25 (WebCore::MultipleTrackList::enable):
 26 (WebCore::MultipleTrackList::disable):
 27 * dom/MultipleTrackList.h:
 28 * dom/Stream.h:
 29 * dom/TrackList.cpp:
 30 (WebCore::TrackList::clear):
 31 (WebCore::TrackList::associateStream):
 32 (WebCore::TrackList::associatedStreamLabel):
 33 (WebCore::TrackList::trackFailed):
 34 (WebCore::TrackList::scriptExecutionContext):
 35 * dom/TrackList.h:
 36 * page/MediaStreamClient.h:
 37 * page/MediaStreamController.cpp:
 38 (WebCore::MediaStreamController::enableAudioTrack):
 39 (WebCore::MediaStreamController::disableAudioTrack):
 40 (WebCore::MediaStreamController::selectVideoTrack):
 41 (WebCore::MediaStreamController::streamGenerated):
 42 (WebCore::MediaStreamController::audioTrackFailed):
 43 (WebCore::MediaStreamController::videoTrackFailed):
 44 * page/MediaStreamController.h:
 45 * page/MediaStreamFrameController.cpp:
 46 (WebCore::MediaStreamFrameController::unregister):
 47 (WebCore::MediaStreamFrameController::enterDetachedState):
 48 (WebCore::MediaStreamFrameController::disconnectFrame):
 49 (WebCore::MediaStreamFrameController::enableAudioTrack):
 50 (WebCore::MediaStreamFrameController::disableAudioTrack):
 51 (WebCore::MediaStreamFrameController::selectVideoTrack):
 52 (WebCore::MediaStreamFrameController::streamGenerated):
 53 (WebCore::MediaStreamFrameController::audioTrackFailed):
 54 (WebCore::MediaStreamFrameController::videoTrackFailed):
 55 * page/MediaStreamFrameController.h:
 56 (WebCore::MediaStreamFrameController::ClientBase::isGenericClient):
 57 (WebCore::MediaStreamFrameController::GenericClient::GenericClient):
 58 (WebCore::MediaStreamFrameController::GenericClient::~GenericClient):
 59 (WebCore::MediaStreamFrameController::GenericClient::isGenericClient):
 60 (WebCore::MediaStreamFrameController::GenericClient::unregister):
 61
1622011-05-31 Oliver Varga <Varga.Oliver@stud.u-szeged.hu>
263
364 Reviewed by Nikolas Zimmermann.

Source/WebCore/dom/ExclusiveTrackList.cpp

@@void ExclusiveTrackList::select(long index, ExceptionCode& ec)
6060 return;
6161
6262 m_selectedIndex = index;
 63
 64#if ENABLE(MEDIA_STREAM)
 65 if (mediaStreamFrameController())
 66 mediaStreamFrameController()->selectVideoTrack(associatedStreamLabel(), index);
 67#endif
 68
6369 postChangeEvent();
6470}
6571
 72#if ENABLE(MEDIA_STREAM)
 73void ExclusiveTrackList::trackFailed(unsigned long index)
 74{
 75 if (m_selectedIndex == static_cast<long>(index))
 76 m_selectedIndex = NoSelection;
 77
 78 TrackList::trackFailed(index);
 79}
 80#endif
 81
6682ExclusiveTrackList* ExclusiveTrackList::toExclusiveTrackList()
6783{
6884 return this;

Source/WebCore/dom/ExclusiveTrackList.h

@@public:
4444
4545 virtual void clear();
4646
 47#if ENABLE(MEDIA_STREAM)
 48 virtual void trackFailed(unsigned long index);
 49#endif
 50
4751 // EventTarget implementation.
4852 virtual ExclusiveTrackList* toExclusiveTrackList();
4953

Source/WebCore/dom/GeneratedStream.cpp

2929
3030#include "Event.h"
3131#include "EventNames.h"
 32#include "ExclusiveTrackList.h"
3233#include "MediaStreamFrameController.h"
 34#include "MultipleTrackList.h"
3335#include "ScriptExecutionContext.h"
3436
3537namespace WebCore {

@@public:
5759 Callback m_callback;
5860};
5961
60 PassRefPtr<GeneratedStream> GeneratedStream::create(MediaStreamFrameController* frameController, const String& label)
 62PassRefPtr<GeneratedStream> GeneratedStream::create(MediaStreamFrameController* frameController, const String& label, PassRefPtr<MultipleTrackList> audioTracks, PassRefPtr<ExclusiveTrackList> videoTracks)
6163{
62  return adoptRef(new GeneratedStream(frameController, label));
 64 return adoptRef(new GeneratedStream(frameController, label, audioTracks, videoTracks));
6365}
6466
65 GeneratedStream::GeneratedStream(MediaStreamFrameController* frameController, const String& label)
 67GeneratedStream::GeneratedStream(MediaStreamFrameController* frameController, const String& label, PassRefPtr<MultipleTrackList> audioTracks, PassRefPtr<ExclusiveTrackList> videoTracks)
6668 : Stream(frameController, label, true)
 69 , m_audioTracks(audioTracks)
 70 , m_videoTracks(videoTracks)
6771{
 72 ASSERT(m_audioTracks);
 73 ASSERT(m_videoTracks);
 74 m_audioTracks->associateStream(label);
 75 m_videoTracks->associateStream(label);
6876}
6977
7078GeneratedStream::~GeneratedStream()

@@void GeneratedStream::detachEmbedder()
8492 Stream::detachEmbedder();
8593}
8694
 95void GeneratedStream::streamEnded()
 96{
 97 m_audioTracks->clear();
 98 m_videoTracks->clear();
 99
 100 Stream::streamEnded();
 101}
 102
 103PassRefPtr<MultipleTrackList> GeneratedStream::audioTracks() const
 104{
 105 return m_audioTracks;
 106}
 107
 108PassRefPtr<ExclusiveTrackList> GeneratedStream::videoTracks() const
 109{
 110 return m_videoTracks;
 111}
 112
87113void GeneratedStream::stop()
88114{
89115 if (!mediaStreamFrameController() || m_readyState == ENDED)
90116 return;
91117
92118 mediaStreamFrameController()->stopGeneratedStream(label());
 119 m_audioTracks->clear();
 120 m_videoTracks->clear();
93121
94122 m_readyState = ENDED;
95123

Source/WebCore/dom/GeneratedStream.h

3232
3333namespace WebCore {
3434
 35class ExclusiveTrackList;
 36class MultipleTrackList;
 37
3538class GeneratedStream : public Stream {
3639public:
37  // FIXME: add audio and video tracks when available.
38  static PassRefPtr<GeneratedStream> create(MediaStreamFrameController*, const String& label);
 40 static PassRefPtr<GeneratedStream> create(MediaStreamFrameController*, const String& label, PassRefPtr<MultipleTrackList> audioTracks, PassRefPtr<ExclusiveTrackList> videoTracks);
3941 virtual ~GeneratedStream();
4042
4143 void stop();
4244
 45 PassRefPtr<MultipleTrackList> audioTracks() const;
 46 PassRefPtr<ExclusiveTrackList> videoTracks() const;
 47
4348 // MediaStreamFrameController::StreamClient implementation.
4449 virtual void detachEmbedder();
 50 virtual void streamEnded();
4551
4652 // EventTarget.
4753 virtual GeneratedStream* toGeneratedStream();
4854
4955private:
50  GeneratedStream(MediaStreamFrameController*, const String& label);
 56 GeneratedStream(MediaStreamFrameController*, const String& label, PassRefPtr<MultipleTrackList> audioTracks, PassRefPtr<ExclusiveTrackList> videoTracks);
5157 class DispatchUpdateTask;
5258 friend class DispatchUpdateTask;
5359
5460 void onStop();
 61
 62 RefPtr<MultipleTrackList> m_audioTracks;
 63 RefPtr<ExclusiveTrackList> m_videoTracks;
5564};
5665
5766} // namespace WebCore

Source/WebCore/dom/GeneratedStream.idl

@@module core {
3030 ] GeneratedStream : Stream {
3131 void stop();
3232
33  // FIXME: implement audio and video tracks when available.
 33 // Track control.
 34 readonly attribute MultipleTrackList audioTracks;
 35 readonly attribute ExclusiveTrackList videoTracks;
3436 };
3537
3638}

Source/WebCore/dom/MultipleTrackList.cpp

@@void MultipleTrackList::clear()
5454 TrackList::clear();
5555}
5656
 57#if ENABLE(MEDIA_STREAM)
 58void MultipleTrackList::trackFailed(unsigned long index)
 59{
 60 TrackList::trackFailed(index);
 61 m_isEnabled.remove(index);
 62}
 63#endif
 64
5765bool MultipleTrackList::isEnabled(unsigned long index, ExceptionCode& ec) const
5866{
5967 return checkIndex(index, ec) ? m_isEnabled[index] : false;

@@void MultipleTrackList::enable(unsigned long index, ExceptionCode& ec)
6573 return;
6674
6775 m_isEnabled[index] = true;
 76
 77#if ENABLE(MEDIA_STREAM)
 78 if (mediaStreamFrameController())
 79 mediaStreamFrameController()->enableAudioTrack(associatedStreamLabel(), index);
 80#endif
 81
6882 postChangeEvent();
6983}
7084

@@void MultipleTrackList::disable(unsigned long index, ExceptionCode& ec)
7488 return;
7589
7690 m_isEnabled[index] = false;
 91
 92#if ENABLE(MEDIA_STREAM)
 93 if (mediaStreamFrameController())
 94 mediaStreamFrameController()->disableAudioTrack(associatedStreamLabel(), index);
 95#endif
 96
7797 postChangeEvent();
7898}
7999

Source/WebCore/dom/MultipleTrackList.h

@@public:
4545
4646 virtual void clear();
4747
 48#if ENABLE(MEDIA_STREAM)
 49 virtual void trackFailed(unsigned long index);
 50#endif
 51
4852 // EventTarget implementation.
4953 virtual MultipleTrackList* toMultipleTrackList();
5054

Source/WebCore/dom/Stream.h

@@public:
5252
5353 // FIXME: implement the record method when StreamRecorder is available.
5454
55  DEFINE_ATTRIBUTE_EVENT_LISTENER(readystatechange);
5655 DEFINE_ATTRIBUTE_EVENT_LISTENER(ended);
5756
5857 unsigned short readyState() const { return m_readyState; }

Source/WebCore/dom/TrackList.cpp

@@const String& TrackList::getLanguage(unsigned long index, ExceptionCode& ec) con
103103
104104void TrackList::clear()
105105{
 106#if ENABLE(MEDIA_STREAM)
 107 m_associatedStreamLabel = String();
 108#endif
 109
 110 if (m_tracks.isEmpty())
 111 return;
 112
106113 m_tracks.clear();
 114
107115 postChangeEvent();
108116}
109117

@@void TrackList::dispatchChangeEvent(int)
123131 dispatchEvent(Event::create(eventNames().changeEvent, false, false));
124132}
125133
 134#if ENABLE(MEDIA_STREAM)
 135void TrackList::associateStream(const String& label)
 136{
 137 ASSERT(m_associatedStreamLabel.isNull());
 138 m_associatedStreamLabel = label;
 139}
 140
 141const String& TrackList::associatedStreamLabel() const
 142{
 143 return m_associatedStreamLabel;
 144}
 145
 146void TrackList::trackFailed(unsigned long index)
 147{
 148 ASSERT(index < length());
 149 m_tracks.remove(index);
 150 postChangeEvent();
 151}
 152#endif
 153
126154TrackList* TrackList::toTrackList()
127155{
128156 return this;

@@TrackList* TrackList::toTrackList()
130158
131159ScriptExecutionContext* TrackList::scriptExecutionContext() const
132160{
133  // FIXME: provide an script execution context for HTML Media Element and MediaStream API use cases.
134  // For the MediaStream API: https://bugs.webkit.org/show_bug.cgi?id=60205
 161#if ENABLE(MEDIA_STREAM)
 162 if (mediaStreamFrameController())
 163 return mediaStreamFrameController()->scriptExecutionContext();
 164#endif
 165
 166 // FIXME: provide an script execution context for HTML Media Element use case.
135167 // For the HTML Media Element: https://bugs.webkit.org/show_bug.cgi?id=61127
136168 return 0;
137169}

Source/WebCore/dom/TrackList.h

@@private:
5858typedef Vector<RefPtr<Track> > TrackVector;
5959
6060class TrackList : public RefCounted<TrackList>,
 61#if ENABLE(MEDIA_STREAM)
 62 public MediaStreamFrameController::GenericClient,
 63#endif
6164 public EventTarget {
6265public:
6366 static PassRefPtr<TrackList> create(const TrackVector&);

@@public:
7376
7477 virtual void clear();
7578
 79#if ENABLE(MEDIA_STREAM)
 80 void associateStream(const String& streamLabel);
 81 const String& associatedStreamLabel() const;
 82 virtual void trackFailed(unsigned long index);
 83#endif
 84
7685 // EventTarget implementation.
7786 virtual TrackList* toTrackList();
7887 virtual ScriptExecutionContext* scriptExecutionContext() const;

@@private:
124133
125134 EventTargetData m_eventTargetData;
126135 TrackVector m_tracks;
 136
 137#if ENABLE(MEDIA_STREAM)
 138 String m_associatedStreamLabel;
 139#endif
127140};
128141
129142} // namespace WebCore

Source/WebCore/page/MediaStreamClient.h

@@public:
5252 // Stop a generated stream.
5353 virtual void stopGeneratedStream(const String& streamLabel) = 0;
5454
 55 // Enable/disable an audio track in a generated stream.
 56 virtual void enableAudioTrack(const String& streamLabel, unsigned long index) = 0;
 57 virtual void disableAudioTrack(const String& streamLabel, unsigned long index) = 0;
 58
 59 // Select a video track in a generated stream.
 60 virtual void selectVideoTrack(const String& streamLabel, long index) = 0;
 61
5562protected:
5663 virtual ~MediaStreamClient() { }
5764};

Source/WebCore/page/MediaStreamController.cpp

2727
2828#if ENABLE(MEDIA_STREAM)
2929
 30#include "ExclusiveTrackList.h"
3031#include "MediaStreamFrameController.h"
 32#include "MultipleTrackList.h"
3133#include "SecurityOrigin.h"
3234#include <wtf/Vector.h>
3335

@@void MediaStreamController::stopGeneratedStream(const String& streamLabel)
117119 m_client->stopGeneratedStream(streamLabel);
118120}
119121
120 void MediaStreamController::streamGenerated(int controllerRequestId, const String& streamLabel)
 122void MediaStreamController::enableAudioTrack(const String& streamLabel, unsigned long index)
 123{
 124 m_client->enableAudioTrack(streamLabel, index);
 125}
 126
 127void MediaStreamController::disableAudioTrack(const String& streamLabel, unsigned long index)
 128{
 129 m_client->disableAudioTrack(streamLabel, index);
 130}
 131
 132void MediaStreamController::selectVideoTrack(const String& streamLabel, long index)
 133{
 134 m_client->selectVideoTrack(streamLabel, index);
 135}
 136
 137void MediaStreamController::streamGenerated(int controllerRequestId, const String& streamLabel, PassRefPtr<MultipleTrackList> audioTracks, PassRefPtr<ExclusiveTrackList> videoTracks)
121138{
122139 // Don't assert since the frame controller can have been destroyed while the request reply was coming back.
123140 if (m_requests.contains(controllerRequestId)) {

@@void MediaStreamController::streamGenerated(int controllerRequestId, const Strin
125142 registerStream(streamLabel, request.frameController());
126143 m_requests.remove(controllerRequestId);
127144 ASSERT(request.frameController());
128  request.frameController()->streamGenerated(request.localId(), streamLabel);
 145 request.frameController()->streamGenerated(request.localId(), streamLabel, audioTracks, videoTracks);
129146 }
130147}
131148

@@void MediaStreamController::streamFailed(const String& streamLabel)
146163 m_streams.get(streamLabel)->streamFailed(streamLabel);
147164}
148165
 166void MediaStreamController::audioTrackFailed(const String& streamLabel, unsigned long index)
 167{
 168 // Don't assert since the frame controller can have been destroyed by the time this is called.
 169 if (m_streams.contains(streamLabel))
 170 m_streams.get(streamLabel)->audioTrackFailed(streamLabel, index);
 171}
 172
 173void MediaStreamController::videoTrackFailed(const String& streamLabel, unsigned long index)
 174{
 175 // Don't assert since the frame controller can have been destroyed by the time this is called.
 176 if (m_streams.contains(streamLabel))
 177 m_streams.get(streamLabel)->videoTrackFailed(streamLabel, index);
 178}
 179
149180} // namespace WebCore
150181
151182#endif // ENABLE(MEDIA_STREAM)

Source/WebCore/page/MediaStreamController.h

3636
3737namespace WebCore {
3838
 39class ExclusiveTrackList;
3940class MediaStreamClient;
4041class MediaStreamFrameController;
 42class MultipleTrackList;
4143class SecurityOrigin;
4244
4345class MediaStreamController {

@@public:
5153
5254 void generateStream(MediaStreamFrameController*, int requestId, GenerateStreamOptionFlags, PassRefPtr<SecurityOrigin>);
5355 void stopGeneratedStream(const String& streamLabel);
 56 void enableAudioTrack(const String& streamLabel, unsigned long index);
 57 void disableAudioTrack(const String& streamLabel, unsigned long index);
 58 void selectVideoTrack(const String& streamLabel, long index);
5459
55  void streamGenerated(int requestId, const String& streamLabel);
 60 void streamGenerated(int requestId, const String& streamLabel, PassRefPtr<MultipleTrackList> audioTracks, PassRefPtr<ExclusiveTrackList> videoTracks);
5661 void streamGenerationFailed(int requestId, NavigatorUserMediaError::ErrorCode);
5762 void streamFailed(const String& streamLabel);
 63 void audioTrackFailed(const String& streamLabel, unsigned long index);
 64 void videoTrackFailed(const String& streamLabel, unsigned long index);
5865
5966private:
6067 int registerRequest(int localRequestId, MediaStreamFrameController*);

Source/WebCore/page/MediaStreamFrameController.cpp

2929
3030#include "DOMWindow.h"
3131#include "Document.h"
 32#include "ExclusiveTrackList.h"
3233#include "Frame.h"
3334#include "GeneratedStream.h"
3435#include "MediaStreamController.h"
 36#include "MultipleTrackList.h"
3537#include "NavigatorUserMediaErrorCallback.h"
3638#include "NavigatorUserMediaSuccessCallback.h"
3739#include "Page.h"

@@void MediaStreamFrameController::unregister(StreamClient* client)
172174 m_streams.remove(client->clientId());
173175}
174176
 177void MediaStreamFrameController::unregister(GenericClient* client)
 178{
 179 ASSERT(m_clients.contains(client->clientId()));
 180 m_clients.remove(client->clientId());
 181}
 182
175183Stream* MediaStreamFrameController::getStreamFromLabel(const String& label) const
176184{
177185 ASSERT(m_streams.contains(label));

@@void MediaStreamFrameController::enterDetachedState()
188196
189197 m_requests.abortAll();
190198 m_streams.detachEmbedder();
 199 m_clients.detachEmbedder();
191200 m_isInDetachedState = true;
192201}
193202

@@void MediaStreamFrameController::disconnectFrame()
216225
217226 ASSERT(m_requests.isEmpty());
218227 m_streams.unregisterAll();
 228 m_clients.unregisterAll();
219229
220230 m_frame = 0;
221231}

@@void MediaStreamFrameController::stopGeneratedStream(const String& streamLabel)
297307 pageController()->stopGeneratedStream(streamLabel);
298308}
299309
300 void MediaStreamFrameController::streamGenerated(int requestId, const String& label)
 310void MediaStreamFrameController::enableAudioTrack(const String& streamLabel, unsigned long index)
 311{
 312 // Don't assert since the audio tracks don't necessarily keep alive their associated generated stream object.
 313 if (!m_streams.contains(streamLabel))
 314 return;
 315
 316 if (isClientAvailable())
 317 pageController()->enableAudioTrack(streamLabel, index);
 318}
 319
 320void MediaStreamFrameController::disableAudioTrack(const String& streamLabel, unsigned long index)
 321{
 322 // Don't assert since the audio tracks don't necessarily keep alive their associated generated stream object.
 323 if (!m_streams.contains(streamLabel))
 324 return;
 325
 326 if (isClientAvailable())
 327 pageController()->disableAudioTrack(streamLabel, index);
 328}
 329
 330void MediaStreamFrameController::selectVideoTrack(const String& streamLabel, long index)
 331{
 332 // Don't assert since the audio tracks don't necessarily keep alive their associated generated stream object.
 333 if (!m_streams.contains(streamLabel))
 334 return;
 335
 336 if (isClientAvailable())
 337 pageController()->selectVideoTrack(streamLabel, index);
 338}
 339
 340void MediaStreamFrameController::streamGenerated(int requestId, const String& label, PassRefPtr<MultipleTrackList> audioTracksParam, PassRefPtr<ExclusiveTrackList> videoTracksParam)
301341{
302342 // Don't assert since the request can have been aborted as a result of embedder detachment.
303343 if (!m_requests.contains(requestId))

@@void MediaStreamFrameController::streamGenerated(int requestId, const String& la
305345
306346 ASSERT(m_requests.get(requestId)->isGenerateStreamRequest());
307347 ASSERT(!label.isNull());
 348 ASSERT(audioTracksParam);
 349 ASSERT(videoTracksParam);
 350
 351 RefPtr<MultipleTrackList> audioTracks = audioTracksParam;
 352 RefPtr<ExclusiveTrackList> videoTracks = videoTracksParam;
 353
 354 int audioTracksClientId = m_clients.getNextId();
 355 audioTracks->associateFrameController(this, audioTracksClientId);
 356 m_clients.add(audioTracksClientId, audioTracks.get());
 357
 358 int videoTracksClientId = m_clients.getNextId();
 359 videoTracks->associateFrameController(this, videoTracksClientId);
 360 m_clients.add(videoTracksClientId, videoTracks.get());
308361
309362 RefPtr<GenerateStreamRequest> streamRequest = static_cast<GenerateStreamRequest*>(m_requests.get(requestId).get());
310  RefPtr<GeneratedStream> generatedStream = GeneratedStream::create(this, label);
 363 RefPtr<GeneratedStream> generatedStream = GeneratedStream::create(this, label, audioTracks.release(), videoTracks.release());
311364 m_streams.add(label, generatedStream.get());
312365 m_requests.remove(requestId);
313366 streamRequest->successCallback()->handleEvent(generatedStream.get());

@@void MediaStreamFrameController::streamFailed(const String& label)
335388 getStreamFromLabel(label)->streamEnded();
336389}
337390
 391void MediaStreamFrameController::audioTrackFailed(const String& label, unsigned long index)
 392{
 393 Stream* stream = getStreamFromLabel(label);
 394 ASSERT(stream->isGeneratedStream());
 395 static_cast<GeneratedStream*>(stream)->audioTracks()->trackFailed(index);
 396}
 397
 398void MediaStreamFrameController::videoTrackFailed(const String& label, unsigned long index)
 399{
 400 Stream* stream = getStreamFromLabel(label);
 401 ASSERT(stream->isGeneratedStream());
 402 static_cast<GeneratedStream*>(stream)->videoTracks()->trackFailed(index);
 403}
338404
339405} // namespace WebCore
340406

Source/WebCore/page/MediaStreamFrameController.h

3737
3838namespace WebCore {
3939
 40class ExclusiveTrackList;
4041class Frame;
4142class GeneratedStream;
4243class MediaStreamController;
 44class MultipleTrackList;
4345class NavigatorUserMediaErrorCallback;
4446class NavigatorUserMediaSuccessCallback;
4547class Page;

@@public:
6769
6870 virtual bool isStream() const { return false; }
6971 virtual bool isGeneratedStream() const { return false; }
 72 virtual bool isGenericClient() const { return false; }
7073
7174 // Called when the frame controller is being disconnected to the MediaStreamClient embedder.
7275 // Clients should override this to send any required shutdown messages.

@@public:
122125 bool m_isGeneratedStream;
123126 };
124127
 128 // Generic clients are objects that require access to the frame controller but don't have a global id (like streams do)
 129 // or need to receive any messages from the embedder client.
 130 class GenericClient : public ClientBase<int> {
 131 public:
 132 GenericClient() { }
 133 GenericClient(MediaStreamFrameController* frameController, int id) : ClientBase<int>(frameController, id) { }
 134 virtual ~GenericClient() { unregister(); }
 135 virtual bool isGenericClient() { return true; }
 136
 137 private:
 138 virtual void unregister() { unregisterClient(this); }
 139 };
 140
125141 MediaStreamFrameController(Frame*);
126142 virtual ~MediaStreamFrameController();
127143

@@public:
142158 // Stop a generated stream.
143159 void stopGeneratedStream(const String& streamLabel);
144160
 161 // Enable/disable an audio track in a generated stream.
 162 void enableAudioTrack(const String& streamLabel, unsigned long index);
 163 void disableAudioTrack(const String& streamLabel, unsigned long index);
 164
 165 // Select a video track in a generated stream.
 166 void selectVideoTrack(const String& streamLabel, long index);
 167
145168 // --- Calls coming back from the controller. --- //
146169
147170 // Report the generation of a new local stream.
148  void streamGenerated(int requestId, const String& streamLabel);
 171 void streamGenerated(int requestId, const String& streamLabel, PassRefPtr<MultipleTrackList> audioTracks, PassRefPtr<ExclusiveTrackList> videoTracks);
149172
150173 // Report a failure in the generation of a new stream.
151174 void streamGenerationFailed(int requestId, NavigatorUserMediaError::ErrorCode);

@@public:
153176 // Report the end of a stream for external reasons.
154177 void streamFailed(const String& streamLabel);
155178
 179 // Report the unexpected unavailability of a live media track.
 180 void audioTrackFailed(const String& streamLabel, unsigned long index);
 181 void videoTrackFailed(const String& streamLabel, unsigned long index);
 182
156183private:
157184 class Request;
158185 class GenerateStreamRequest;

@@private:
187214 // Streams are a special class of clients since they are identified by a global label string instead of an id.
188215 typedef ClientMapBase<String> StreamMap;
189216
 217 // All other types of clients use autogenerated integer ids.
 218 class ClientMap : public IdGenerator, public ClientMapBase<int> { };
 219
190220 // Detached from a page, and hence from a embedder client.
191221 void enterDetachedState();
192222
193223 void unregister(StreamClient*);
 224 void unregister(GenericClient*);
194225 MediaStreamController* pageController() const;
195226 Stream* getStreamFromLabel(const String&) const;
196227
197228 RequestMap m_requests;
 229 ClientMap m_clients;
198230 StreamMap m_streams;
199231
200232 Frame* m_frame;