OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 23 matching lines...) Expand all Loading... |
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 virtual void GenerateStream( | 35 virtual void GenerateStream( |
36 int request_id, | 36 int request_id, |
37 MediaStreamDispatcherEventHandler* event_handler, | 37 MediaStreamDispatcherEventHandler* event_handler, |
38 media_stream::StreamOptions components, | 38 media_stream::StreamOptions components, |
39 const std::string& security_origin); | 39 const std::string& security_origin); |
40 | 40 |
41 // Stop a started stream. Label is the label provided in OnStreamGenerated. | 41 // Stop a started stream. Label is the label provided in OnStreamGenerated. |
42 virtual void StopStream(const std::string& label); | 42 virtual void StopStream(const std::string& label); |
43 | 43 |
| 44 // Request to enumerate devices. |
| 45 void EnumerateDevices(int request_id, |
| 46 MediaStreamDispatcherEventHandler* event_handler, |
| 47 media_stream::MediaStreamType type, |
| 48 const std::string& security_origin); |
| 49 |
| 50 // Request to open a device. |
| 51 void OpenDevice(int request_id, |
| 52 MediaStreamDispatcherEventHandler* event_handler, |
| 53 const std::string& device_id, |
| 54 media_stream::MediaStreamType type, |
| 55 const std::string& security_origin); |
| 56 |
| 57 // Close a started device. |label| is provided in OnDeviceOpened. |
| 58 void CloseDevice(const std::string& label); |
| 59 |
44 // Check if the label is a valid stream. | 60 // Check if the label is a valid stream. |
45 virtual bool IsStream(const std::string& label); | 61 virtual bool IsStream(const std::string& label); |
46 // Get the video session_id given a label. The label identifies a stream. | 62 // Get the video session_id given a label. The label identifies a stream. |
47 // index is the index in the video_device_array of the stream. | 63 // index is the index in the video_device_array of the stream. |
48 virtual int video_session_id(const std::string& label, int index); | 64 virtual int video_session_id(const std::string& label, int index); |
49 // Returns an audio session_id given a label and an index. | 65 // Returns an audio session_id given a label and an index. |
50 virtual int audio_session_id(const std::string& label, int index); | 66 virtual int audio_session_id(const std::string& label, int index); |
51 | 67 |
52 private: | 68 private: |
53 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, Basic); | 69 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicStream); |
| 70 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicVideoDevice); |
54 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure); | 71 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure); |
55 | 72 |
56 struct Request; | 73 struct Request; |
57 | 74 |
58 // Private class for keeping track of opened devices and who have | 75 // Private class for keeping track of opened devices and who have |
59 // opened it. | 76 // opened it. |
60 struct Stream; | 77 struct Stream; |
61 | 78 |
62 // Messages from the browser. | 79 // Messages from the browser. |
63 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 80 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
64 void OnStreamGenerated( | 81 void OnStreamGenerated( |
65 int request_id, | 82 int request_id, |
66 const std::string& label, | 83 const std::string& label, |
67 const media_stream::StreamDeviceInfoArray& audio_array, | 84 const media_stream::StreamDeviceInfoArray& audio_array, |
68 const media_stream::StreamDeviceInfoArray& video_array); | 85 const media_stream::StreamDeviceInfoArray& video_array); |
69 void OnStreamGenerationFailed(int request_id); | 86 void OnStreamGenerationFailed(int request_id); |
70 void OnVideoDeviceFailed(const std::string& label, int index); | 87 void OnVideoDeviceFailed(const std::string& label, int index); |
71 void OnAudioDeviceFailed(const std::string& label, int index); | 88 void OnAudioDeviceFailed(const std::string& label, int index); |
| 89 void OnDevicesEnumerated( |
| 90 int request_id, |
| 91 const media_stream::StreamDeviceInfoArray& device_array); |
| 92 void OnDevicesEnumerationFailed(int request_id); |
| 93 void OnDeviceOpened( |
| 94 int request_id, |
| 95 const std::string& label, |
| 96 const media_stream::StreamDeviceInfo& device_info); |
| 97 void OnDeviceOpenFailed(int request_id); |
72 | 98 |
73 int next_ipc_id_; | 99 int next_ipc_id_; |
74 typedef std::map<std::string, Stream> LabelStreamMap; | 100 typedef std::map<std::string, Stream> LabelStreamMap; |
75 LabelStreamMap label_stream_map_; | 101 LabelStreamMap label_stream_map_; |
76 | 102 |
77 // List of calls made to GenerateStream that has not yet completed. | 103 // List of calls made to GenerateStream that has not yet completed. |
78 typedef std::list<Request> RequestList; | 104 typedef std::list<Request> RequestList; |
79 RequestList requests_; | 105 RequestList requests_; |
80 | 106 |
81 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); | 107 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); |
82 }; | 108 }; |
83 | 109 |
84 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ | 110 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ |
OLD | NEW |