| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // Get the video session_id given a label. The label identifies a stream. | 45 // 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. | 46 // index is the index in the video_device_array of the stream. |
| 47 int video_session_id(const std::string& label, int index); | 47 int video_session_id(const std::string& label, int index); |
| 48 // Returns an audio session_id given a label and an index. | 48 // Returns an audio session_id given a label and an index. |
| 49 int audio_session_id(const std::string& label, int index); | 49 int audio_session_id(const std::string& label, int index); |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, Basic); | 52 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, Basic); |
| 53 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure); | 53 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure); |
| 54 | 54 |
| 55 struct Request { | 55 struct Request; |
| 56 Request(MediaStreamDispatcherEventHandler* handler, | |
| 57 int request_id, | |
| 58 int ipc_request) | |
| 59 : handler(handler), | |
| 60 request_id(request_id), | |
| 61 ipc_request(ipc_request) { | |
| 62 } | |
| 63 MediaStreamDispatcherEventHandler* handler; | |
| 64 int request_id; | |
| 65 int ipc_request; | |
| 66 }; | |
| 67 | 56 |
| 68 // Private class for keeping track of opened devices and who have | 57 // Private class for keeping track of opened devices and who have |
| 69 // opened it. | 58 // opened it. |
| 70 struct Stream { | 59 struct Stream; |
| 71 Stream(); | |
| 72 ~Stream(); | |
| 73 MediaStreamDispatcherEventHandler* handler; | |
| 74 media_stream::StreamDeviceInfoArray audio_array; | |
| 75 media_stream::StreamDeviceInfoArray video_array; | |
| 76 }; | |
| 77 | 60 |
| 78 // Messages from the browser. | 61 // Messages from the browser. |
| 79 virtual bool OnMessageReceived(const IPC::Message& message); | 62 virtual bool OnMessageReceived(const IPC::Message& message); |
| 80 void OnStreamGenerated( | 63 void OnStreamGenerated( |
| 81 int request_id, | 64 int request_id, |
| 82 const std::string& label, | 65 const std::string& label, |
| 83 const media_stream::StreamDeviceInfoArray& audio_array, | 66 const media_stream::StreamDeviceInfoArray& audio_array, |
| 84 const media_stream::StreamDeviceInfoArray& video_array); | 67 const media_stream::StreamDeviceInfoArray& video_array); |
| 85 void OnStreamGenerationFailed(int request_id); | 68 void OnStreamGenerationFailed(int request_id); |
| 86 void OnVideoDeviceFailed(const std::string& label, int index); | 69 void OnVideoDeviceFailed(const std::string& label, int index); |
| 87 void OnAudioDeviceFailed(const std::string& label, int index); | 70 void OnAudioDeviceFailed(const std::string& label, int index); |
| 88 | 71 |
| 89 int next_ipc_id_; | 72 int next_ipc_id_; |
| 90 typedef std::map<std::string, Stream> LabelStreamMap; | 73 typedef std::map<std::string, Stream> LabelStreamMap; |
| 91 LabelStreamMap label_stream_map_; | 74 LabelStreamMap label_stream_map_; |
| 92 | 75 |
| 93 // List of calls made to GenerateStream that has not yet completed. | 76 // List of calls made to GenerateStream that has not yet completed. |
| 94 typedef std::list<Request> RequestList; | 77 typedef std::list<Request> RequestList; |
| 95 RequestList requests_; | 78 RequestList requests_; |
| 96 | 79 |
| 97 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); | 80 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); |
| 98 }; | 81 }; |
| 99 | 82 |
| 100 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ | 83 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ |
| OLD | NEW |