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/strings/stringprintf.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "content/public/common/media_stream_request.h" | 8 #include "content/public/common/media_stream_request.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 MockMediaStreamDispatcher::MockMediaStreamDispatcher() | 13 MockMediaStreamDispatcher::MockMediaStreamDispatcher() |
14 : MediaStreamDispatcher(NULL), | 14 : MediaStreamDispatcher(NULL), |
15 request_id_(-1), | 15 request_id_(-1), |
16 request_stream_counter_(0), | 16 request_stream_counter_(0), |
17 stop_audio_device_counter_(0), | 17 stop_audio_device_counter_(0), |
18 stop_video_device_counter_(0), | 18 stop_video_device_counter_(0), |
19 session_id_(0) { | 19 session_id_(0) { |
20 } | 20 } |
21 | 21 |
22 MockMediaStreamDispatcher::~MockMediaStreamDispatcher() {} | 22 MockMediaStreamDispatcher::~MockMediaStreamDispatcher() {} |
23 | 23 |
24 void MockMediaStreamDispatcher::GenerateStream( | 24 void MockMediaStreamDispatcher::GenerateStream( |
25 int request_id, | 25 int request_id, |
26 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 26 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, |
27 const StreamOptions& components, | 27 const StreamOptions& components, |
28 const GURL& url) { | 28 const GURL& url) { |
29 request_id_ = request_id; | 29 request_id_ = request_id; |
30 | 30 |
31 stream_label_ = base::StringPrintf("%s%d","local_stream",request_id); | 31 stream_label_ = "local_stream" + base::IntToString(request_id); |
32 audio_array_.clear(); | 32 audio_array_.clear(); |
33 video_array_.clear(); | 33 video_array_.clear(); |
34 | 34 |
35 if (IsAudioMediaType(components.audio_type)) { | 35 if (IsAudioMediaType(components.audio_type)) { |
36 StreamDeviceInfo audio; | 36 StreamDeviceInfo audio; |
37 audio.device.id = "audio_device_id"; | 37 audio.device.id = "audio_device_id" + base::IntToString(session_id_); |
38 audio.device.name = "microphone"; | 38 audio.device.name = "microphone"; |
39 audio.device.type = components.audio_type; | 39 audio.device.type = components.audio_type; |
40 audio.session_id = session_id_; | 40 audio.session_id = session_id_; |
41 audio_array_.push_back(audio); | 41 audio_array_.push_back(audio); |
42 } | 42 } |
43 if (IsVideoMediaType(components.video_type)) { | 43 if (IsVideoMediaType(components.video_type)) { |
44 StreamDeviceInfo video; | 44 StreamDeviceInfo video; |
45 video.device.id = "video_device_id"; | 45 video.device.id = "video_device_id" + base::IntToString(session_id_); |
46 video.device.name = "usb video camera"; | 46 video.device.name = "usb video camera"; |
47 video.device.type = components.video_type; | 47 video.device.type = components.video_type; |
48 video.session_id = session_id_; | 48 video.session_id = session_id_; |
49 video_array_.push_back(video); | 49 video_array_.push_back(video); |
50 } | 50 } |
51 ++request_stream_counter_; | 51 ++request_stream_counter_; |
52 } | 52 } |
53 | 53 |
54 void MockMediaStreamDispatcher::CancelGenerateStream( | 54 void MockMediaStreamDispatcher::CancelGenerateStream( |
55 int request_id, | 55 int request_id, |
(...skipping 22 matching lines...) Expand all Loading... |
78 int index) { | 78 int index) { |
79 return -1; | 79 return -1; |
80 } | 80 } |
81 | 81 |
82 int MockMediaStreamDispatcher::audio_session_id(const std::string& label, | 82 int MockMediaStreamDispatcher::audio_session_id(const std::string& label, |
83 int index) { | 83 int index) { |
84 return -1; | 84 return -1; |
85 } | 85 } |
86 | 86 |
87 } // namespace content | 87 } // namespace content |
OLD | NEW |