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

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

Issue 8480028: support video device enumeration from renderer process. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: code review Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 22 matching lines...) Expand all
33 // This can be used either of WebKit or a plugin. 33 // This can be used either of WebKit or a plugin.
34 // Note: The event_handler must be valid for as long as the stream exists. 34 // Note: The event_handler must be valid for as long as the stream exists.
35 void GenerateStream(int request_id, 35 void GenerateStream(int request_id,
36 MediaStreamDispatcherEventHandler* event_handler, 36 MediaStreamDispatcherEventHandler* event_handler,
37 media_stream::StreamOptions components, 37 media_stream::StreamOptions components,
38 const std::string& security_origin); 38 const std::string& security_origin);
39 39
40 // Stop a started stream. Label is the label provided in OnStreamGenerated. 40 // Stop a started stream. Label is the label provided in OnStreamGenerated.
41 void StopStream(const std::string& label); 41 void StopStream(const std::string& label);
42 42
43 // Request to enumerate devices.
44 void EnumerateDevices(int request_id,
45 MediaStreamDispatcherEventHandler* event_handler,
46 media_stream::MediaStreamType type,
47 const std::string& security_origin);
48
49 // Request to open a device.
50 void OpenDevice(int request_id,
51 MediaStreamDispatcherEventHandler* event_handler,
52 const std::string& device_id,
53 media_stream::MediaStreamType type,
54 const std::string& security_origin);
55
56 // Close a started device. |label| is provided in OnDeviceOpened.
57 void CloseDevice(const std::string& label);
58
43 // Check if the label is a valid stream. 59 // Check if the label is a valid stream.
44 bool IsStream(const std::string& label); 60 bool IsStream(const std::string& label);
45 // Get the video session_id given a label. The label identifies a stream. 61 // Get the video session_id given a label. The label identifies a stream.
46 // index is the index in the video_device_array of the stream. 62 // index is the index in the video_device_array of the stream.
47 int video_session_id(const std::string& label, int index); 63 int video_session_id(const std::string& label, int index);
48 // Returns an audio session_id given a label and an index. 64 // Returns an audio session_id given a label and an index.
49 int audio_session_id(const std::string& label, int index); 65 int audio_session_id(const std::string& label, int index);
50 66
51 private: 67 private:
52 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, Basic); 68 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicStream);
69 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicVideoDevice);
53 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure); 70 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure);
54 71
55 struct Request; 72 struct Request;
56 73
57 // Private class for keeping track of opened devices and who have 74 // Private class for keeping track of opened devices and who have
58 // opened it. 75 // opened it.
59 struct Stream; 76 struct Stream;
60 77
61 // Messages from the browser. 78 // Messages from the browser.
62 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 79 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
63 void OnStreamGenerated( 80 void OnStreamGenerated(
64 int request_id, 81 int request_id,
65 const std::string& label, 82 const std::string& label,
66 const media_stream::StreamDeviceInfoArray& audio_array, 83 const media_stream::StreamDeviceInfoArray& audio_array,
67 const media_stream::StreamDeviceInfoArray& video_array); 84 const media_stream::StreamDeviceInfoArray& video_array);
68 void OnStreamGenerationFailed(int request_id); 85 void OnStreamGenerationFailed(int request_id);
69 void OnVideoDeviceFailed(const std::string& label, int index); 86 void OnVideoDeviceFailed(const std::string& label, int index);
70 void OnAudioDeviceFailed(const std::string& label, int index); 87 void OnAudioDeviceFailed(const std::string& label, int index);
88 void OnDevicesEnumerated(
89 int request_id,
90 const media_stream::StreamDeviceInfoArray& device_array);
91 void OnDevicesEnumerationFailed(int request_id);
92 void OnDeviceOpened(
93 int request_id,
94 const std::string& label,
95 const media_stream::StreamDeviceInfo& device_info);
96 void OnDeviceOpenFailed(int request_id);
71 97
72 int next_ipc_id_; 98 int next_ipc_id_;
73 typedef std::map<std::string, Stream> LabelStreamMap; 99 typedef std::map<std::string, Stream> LabelStreamMap;
74 LabelStreamMap label_stream_map_; 100 LabelStreamMap label_stream_map_;
75 101
76 // List of calls made to GenerateStream that has not yet completed. 102 // List of calls made to GenerateStream that has not yet completed.
77 typedef std::list<Request> RequestList; 103 typedef std::list<Request> RequestList;
78 RequestList requests_; 104 RequestList requests_;
79 105
80 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); 106 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher);
81 }; 107 };
82 108
83 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ 109 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698