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