Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: content/renderer/media/mock_media_stream_dispatcher.cc

Issue 10928043: Media Related changes for TabCapture API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rename REQUEST_*->MEDIA_REQUEST_* Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 MockMediaStreamDispatcher::MockMediaStreamDispatcher() 10 MockMediaStreamDispatcher::MockMediaStreamDispatcher()
11 : MediaStreamDispatcher(NULL), 11 : MediaStreamDispatcher(NULL),
12 request_id_(-1), 12 request_id_(-1),
13 stop_stream_counter_(0) { 13 stop_stream_counter_(0) {
14 } 14 }
15 15
16 MockMediaStreamDispatcher::~MockMediaStreamDispatcher() {} 16 MockMediaStreamDispatcher::~MockMediaStreamDispatcher() {}
17 17
18 void MockMediaStreamDispatcher::GenerateStream( 18 void MockMediaStreamDispatcher::GenerateStream(
19 int request_id, 19 int request_id,
20 const base::WeakPtr<MediaStreamDispatcherEventHandler>&, 20 const base::WeakPtr<MediaStreamDispatcherEventHandler>&,
21 media_stream::StreamOptions components, 21 const media_stream::StreamOptions& components,
22 const GURL&) { 22 const GURL&) {
23 request_id_ = request_id; 23 request_id_ = request_id;
24 24
25 stream_label_ = StringPrintf("%s%d","local_stream",request_id); 25 stream_label_ = StringPrintf("%s%d","local_stream",request_id);
26 audio_array_.clear(); 26 audio_array_.clear();
27 video_array_.clear(); 27 video_array_.clear();
28 28
29 if (content::IsAudioMediaType(components.audio_type)) { 29 if (content::IsAudioMediaType(components.audio_type)) {
30 media_stream::StreamDeviceInfo audio; 30 media_stream::StreamDeviceInfo audio;
31 audio.device_id = "audio_device_id"; 31 audio.device_id = "audio_device_id";
32 audio.name = "microphone"; 32 audio.name = "microphone";
33 audio.stream_type = components.audio_type; 33 audio.stream_type = components.audio_type;
34 audio.session_id = request_id; 34 audio.session_id = request_id;
35 audio_array_.push_back(audio); 35 audio_array_.push_back(audio);
36 } 36 }
37 if (content::IsVideoMediaType(components.video_type)) { 37 if (content::IsVideoMediaType(components.video_type)) {
38 media_stream::StreamDeviceInfo video; 38 media_stream::StreamDeviceInfo video;
39 video.device_id = "video_device_id"; 39 video.device_id = "video_device_id";
40 video.name = "usb video camera"; 40 video.name = "usb video camera";
41 video.stream_type = components.video_type; 41 video.stream_type = components.video_type;
42 video.session_id = request_id; 42 video.session_id = request_id;
43 video_array_.push_back(video); 43 video_array_.push_back(video);
44 } 44 }
45 } 45 }
46 46
47 void MockMediaStreamDispatcher::GenerateStreamForDevice(
48 int request_id,
49 const base::WeakPtr<MediaStreamDispatcherEventHandler>&,
50 media_stream::StreamOptions components,
51 const std::string& device_id,
52 const GURL&) {
53 request_id_ = request_id;
54
55 stream_label_ = StringPrintf("%s%d","local_stream",request_id);
56 audio_array_.clear();
57 video_array_.clear();
58
59 if (content::IsAudioMediaType(components.audio_type)) {
60 media_stream::StreamDeviceInfo audio;
61 audio.device_id = device_id;
62 audio.name = "Tab Audio Capture";
63 audio.stream_type = components.audio_type;
64 audio.session_id = request_id;
65 audio_array_.push_back(audio);
66 }
67 if (content::IsVideoMediaType(components.video_type)) {
68 media_stream::StreamDeviceInfo video;
69 video.device_id = device_id;
70 video.name = "Tab Video Capture";
71 video.stream_type = components.video_type;
72 video.session_id = request_id;
73 video_array_.push_back(video);
74 }
75 }
76
77 void MockMediaStreamDispatcher::StopStream(const std::string& label) { 47 void MockMediaStreamDispatcher::StopStream(const std::string& label) {
78 ++stop_stream_counter_; 48 ++stop_stream_counter_;
79 } 49 }
80 50
81 bool MockMediaStreamDispatcher::IsStream(const std::string& label) { 51 bool MockMediaStreamDispatcher::IsStream(const std::string& label) {
82 return true; 52 return true;
83 } 53 }
84 54
85 int MockMediaStreamDispatcher::video_session_id(const std::string& label, 55 int MockMediaStreamDispatcher::video_session_id(const std::string& label,
86 int index) { 56 int index) {
87 return -1; 57 return -1;
88 } 58 }
89 59
90 int MockMediaStreamDispatcher::audio_session_id(const std::string& label, 60 int MockMediaStreamDispatcher::audio_session_id(const std::string& label,
91 int index) { 61 int index) {
92 return -1; 62 return -1;
93 } 63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698