OLD | NEW |
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 Loading... |
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 video devices. |
| 44 void EnumerateVideoDevices(int request_id, |
| 45 MediaStreamDispatcherEventHandler* event_handler, |
| 46 const std::string& security_origin); |
| 47 |
| 48 // Request to open a video device. |
| 49 void OpenVideoDevice(int request_id, |
| 50 MediaStreamDispatcherEventHandler* event_handler, |
| 51 const std::string& device_id, |
| 52 const std::string& security_origin); |
| 53 |
| 54 // Close a started video device. |label| is provided in OnVideoDeviceOpened. |
| 55 void CloseVideoDevice(const std::string& label); |
| 56 |
43 // Check if the label is a valid stream. | 57 // Check if the label is a valid stream. |
44 bool IsStream(const std::string& label); | 58 bool IsStream(const std::string& label); |
45 // Get the video session_id given a label. The label identifies a stream. | 59 // 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. | 60 // index is the index in the video_device_array of the stream. |
47 int video_session_id(const std::string& label, int index); | 61 int video_session_id(const std::string& label, int index); |
48 // Returns an audio session_id given a label and an index. | 62 // Returns an audio session_id given a label and an index. |
49 int audio_session_id(const std::string& label, int index); | 63 int audio_session_id(const std::string& label, int index); |
50 | 64 |
51 private: | 65 private: |
52 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, Basic); | 66 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicStream); |
| 67 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicVideoDevice); |
53 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure); | 68 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure); |
54 | 69 |
55 struct Request; | 70 struct Request; |
56 | 71 |
57 // Private class for keeping track of opened devices and who have | 72 // Private class for keeping track of opened devices and who have |
58 // opened it. | 73 // opened it. |
59 struct Stream; | 74 struct Stream; |
60 | 75 |
61 // Messages from the browser. | 76 // Messages from the browser. |
62 virtual bool OnMessageReceived(const IPC::Message& message); | 77 virtual bool OnMessageReceived(const IPC::Message& message); |
63 void OnStreamGenerated( | 78 void OnStreamGenerated( |
64 int request_id, | 79 int request_id, |
65 const std::string& label, | 80 const std::string& label, |
66 const media_stream::StreamDeviceInfoArray& audio_array, | 81 const media_stream::StreamDeviceInfoArray& audio_array, |
67 const media_stream::StreamDeviceInfoArray& video_array); | 82 const media_stream::StreamDeviceInfoArray& video_array); |
68 void OnStreamGenerationFailed(int request_id); | 83 void OnStreamGenerationFailed(int request_id); |
69 void OnVideoDeviceFailed(const std::string& label, int index); | 84 void OnVideoDeviceFailed(const std::string& label, int index); |
70 void OnAudioDeviceFailed(const std::string& label, int index); | 85 void OnAudioDeviceFailed(const std::string& label, int index); |
| 86 void OnVideoDevicesEnumerated( |
| 87 int request_id, |
| 88 const media_stream::StreamDeviceInfoArray& device_array); |
| 89 void OnVideoDevicesEnumerationFailed(int request_id); |
| 90 void OnVideoDeviceOpened( |
| 91 int request_id, |
| 92 const std::string& label, |
| 93 const media_stream::StreamDeviceInfo& device_info); |
| 94 void OnVideoDeviceOpenFailed(int request_id); |
71 | 95 |
72 int next_ipc_id_; | 96 int next_ipc_id_; |
73 typedef std::map<std::string, Stream> LabelStreamMap; | 97 typedef std::map<std::string, Stream> LabelStreamMap; |
74 LabelStreamMap label_stream_map_; | 98 LabelStreamMap label_stream_map_; |
75 | 99 |
76 // List of calls made to GenerateStream that has not yet completed. | 100 // List of calls made to GenerateStream that has not yet completed. |
77 typedef std::list<Request> RequestList; | 101 typedef std::list<Request> RequestList; |
78 RequestList requests_; | 102 RequestList requests_; |
79 | 103 |
80 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); | 104 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); |
81 }; | 105 }; |
82 | 106 |
83 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ | 107 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ |
OLD | NEW |