Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: content/renderer/media/media_stream_dispatcher.h

Issue 7184010: MediaStreamDispatcher (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/media/media_stream_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_
7
8 #include <list>
9 #include <map>
10 #include <string>
11
12 #include "base/basictypes.h"
13 #include "base/message_loop.h"
14 #include "content/common/media/media_stream_options.h"
15 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h"
16 #include "content/renderer/render_view_observer.h"
17
18 // MediaStreamDispatcher is a delegate for the Media Stream API messages.
19 // MediaStreams are used by WebKit to open media devices such as Video Capture
20 // and Audio input devices.
21 // It's the complement of MediaStreamDispatcherHost (owned by
22 // BrowserRenderProcessHost).
23 class MediaStreamDispatcher : public RenderViewObserver {
24 public:
25 explicit MediaStreamDispatcher(RenderView* render_view);
26 virtual ~MediaStreamDispatcher();
27
28 // Request a new media stream to be created.
29 // This can be used either of WebKit or a plugin.
30 // Note: The event_handler must be valid for as long as the stream exists.
31 void GenerateStream(int request_id,
32 MediaStreamDispatcherEventHandler* event_handler,
33 media_stream::StreamOptions components,
34 const std::string& security_origin);
35
36 // Stop a started stream. Label is the label provided in OnStreamGenerated.
37 void StopStream(const std::string& label);
38
39 // Check if the label is a valid stream.
40 bool IsStream(const std::string& label);
41 // Get the video session_id given a label. The label identifies a stream.
42 // index is the index in the video_device_array of the stream.
43 int video_session_id(const std::string& label, int index);
44 // Returns an audio session_id given a label and an index.
45 int audio_session_id(const std::string& label, int index);
46
47 private:
48 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, Basic);
49 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure);
50
51 struct Request {
52 Request(MediaStreamDispatcherEventHandler* handler,
53 int request_id,
54 int ipc_request)
55 : handler(handler),
56 request_id(request_id),
57 ipc_request(ipc_request) {
58 }
59 MediaStreamDispatcherEventHandler* handler;
60 int request_id;
61 int ipc_request;
62 };
63
64 // Private class for keeping track of opened devices and who have
65 // opened it.
66 struct Stream {
67 Stream();
68 ~Stream();
69 MediaStreamDispatcherEventHandler* handler;
70 media_stream::StreamDeviceInfoArray audio_array;
71 media_stream::StreamDeviceInfoArray video_array;
72 };
73
74 // Messages from the browser.
75 virtual bool OnMessageReceived(const IPC::Message& message);
76 void OnStreamGenerated(
77 int request_id,
78 const std::string& label,
79 const media_stream::StreamDeviceInfoArray& audio_array,
80 const media_stream::StreamDeviceInfoArray& video_array);
81 void OnStreamGenerationFailed(int request_id);
82 void OnVideoDeviceFailed(const std::string& label, int index);
83 void OnAudioDeviceFailed(const std::string& label, int index);
84
85 int next_ipc_id_;
86 typedef std::map<std::string, Stream> LabelStreamMap;
87 LabelStreamMap label_stream_map_;
88
89 // List of calls made to GenerateStream that has not yet completed.
90 typedef std::list<Request> RequestList;
91 RequestList requests_;
92
93 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher);
94 };
95
96 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_
OLDNEW
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/media/media_stream_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698