| 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 #include "content/renderer/media/mock_media_stream_dispatcher.h" | 5 #include "content/renderer/media/mock_media_stream_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "content/public/common/media_stream_request.h" | 8 #include "content/public/common/media_stream_request.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 MockMediaStreamDispatcher::MockMediaStreamDispatcher() | 12 MockMediaStreamDispatcher::MockMediaStreamDispatcher() |
| 13 : MediaStreamDispatcher(NULL), | 13 : MediaStreamDispatcher(NULL), |
| 14 request_id_(-1), | 14 request_id_(-1), |
| 15 request_stream_counter_(0), | 15 request_stream_counter_(0), |
| 16 stop_stream_counter_(0) { | 16 stop_stream_counter_(0) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 MockMediaStreamDispatcher::~MockMediaStreamDispatcher() {} | 19 MockMediaStreamDispatcher::~MockMediaStreamDispatcher() {} |
| 20 | 20 |
| 21 void MockMediaStreamDispatcher::GenerateStream( | 21 void MockMediaStreamDispatcher::GenerateStream( |
| 22 int request_id, | 22 int request_id, |
| 23 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 23 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
| 24 const media_stream::StreamOptions& components, | 24 const StreamOptions& components, |
| 25 const GURL& url) { | 25 const GURL& url) { |
| 26 request_id_ = request_id; | 26 request_id_ = request_id; |
| 27 | 27 |
| 28 stream_label_ = StringPrintf("%s%d","local_stream",request_id); | 28 stream_label_ = StringPrintf("%s%d","local_stream",request_id); |
| 29 audio_array_.clear(); | 29 audio_array_.clear(); |
| 30 video_array_.clear(); | 30 video_array_.clear(); |
| 31 | 31 |
| 32 if (IsAudioMediaType(components.audio_type)) { | 32 if (IsAudioMediaType(components.audio_type)) { |
| 33 media_stream::StreamDeviceInfo audio; | 33 StreamDeviceInfo audio; |
| 34 audio.device_id = "audio_device_id"; | 34 audio.device_id = "audio_device_id"; |
| 35 audio.name = "microphone"; | 35 audio.name = "microphone"; |
| 36 audio.stream_type = components.audio_type; | 36 audio.stream_type = components.audio_type; |
| 37 audio.session_id = request_id; | 37 audio.session_id = request_id; |
| 38 audio_array_.push_back(audio); | 38 audio_array_.push_back(audio); |
| 39 } | 39 } |
| 40 if (IsVideoMediaType(components.video_type)) { | 40 if (IsVideoMediaType(components.video_type)) { |
| 41 media_stream::StreamDeviceInfo video; | 41 StreamDeviceInfo video; |
| 42 video.device_id = "video_device_id"; | 42 video.device_id = "video_device_id"; |
| 43 video.name = "usb video camera"; | 43 video.name = "usb video camera"; |
| 44 video.stream_type = components.video_type; | 44 video.stream_type = components.video_type; |
| 45 video.session_id = request_id; | 45 video.session_id = request_id; |
| 46 video_array_.push_back(video); | 46 video_array_.push_back(video); |
| 47 } | 47 } |
| 48 ++request_stream_counter_; | 48 ++request_stream_counter_; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void MockMediaStreamDispatcher::StopStream(const std::string& label) { | 51 void MockMediaStreamDispatcher::StopStream(const std::string& label) { |
| 52 ++stop_stream_counter_; | 52 ++stop_stream_counter_; |
| 53 } | 53 } |
| 54 | 54 |
| 55 bool MockMediaStreamDispatcher::IsStream(const std::string& label) { | 55 bool MockMediaStreamDispatcher::IsStream(const std::string& label) { |
| 56 return true; | 56 return true; |
| 57 } | 57 } |
| 58 | 58 |
| 59 int MockMediaStreamDispatcher::video_session_id(const std::string& label, | 59 int MockMediaStreamDispatcher::video_session_id(const std::string& label, |
| 60 int index) { | 60 int index) { |
| 61 return -1; | 61 return -1; |
| 62 } | 62 } |
| 63 | 63 |
| 64 int MockMediaStreamDispatcher::audio_session_id(const std::string& label, | 64 int MockMediaStreamDispatcher::audio_session_id(const std::string& label, |
| 65 int index) { | 65 int index) { |
| 66 return -1; | 66 return -1; |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace content | 69 } // namespace content |
| OLD | NEW |