media_stream_request.cc revision 68043e1e95eeb07d5cae7aca370b26518b0867d6
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
3// found in the LICENSE file.
4
5#include "content/public/common/media_stream_request.h"
6
7#include "base/logging.h"
8
9namespace content {
10
11bool IsAudioMediaType(MediaStreamType type) {
12  return (type == content::MEDIA_DEVICE_AUDIO_CAPTURE ||
13          type == content::MEDIA_TAB_AUDIO_CAPTURE ||
14          type == content::MEDIA_LOOPBACK_AUDIO_CAPTURE);
15}
16
17bool IsVideoMediaType(MediaStreamType type) {
18  return (type == content::MEDIA_DEVICE_VIDEO_CAPTURE ||
19          type == content::MEDIA_TAB_VIDEO_CAPTURE ||
20          type == content::MEDIA_DESKTOP_VIDEO_CAPTURE);
21}
22
23MediaStreamDevice::MediaStreamDevice()
24    : type(MEDIA_NO_SERVICE),
25      video_facing(MEDIA_VIDEO_FACING_NONE) {
26}
27
28MediaStreamDevice::MediaStreamDevice(
29    MediaStreamType type,
30    const std::string& id,
31    const std::string& name)
32    : type(type),
33      id(id),
34      video_facing(MEDIA_VIDEO_FACING_NONE),
35      name(name) {
36#if defined(OS_ANDROID)
37  if (name.find("front") != std::string::npos) {
38    video_facing = MEDIA_VIDEO_FACING_USER;
39  } else if (name.find("back") != std::string::npos) {
40    video_facing = MEDIA_VIDEO_FACING_ENVIRONMENT;
41  }
42#endif
43}
44
45MediaStreamDevice::MediaStreamDevice(
46    MediaStreamType type,
47    const std::string& id,
48    const std::string& name,
49    int sample_rate,
50    int channel_layout,
51    int frames_per_buffer)
52    : type(type),
53      id(id),
54      video_facing(MEDIA_VIDEO_FACING_NONE),
55      name(name),
56      input(sample_rate, channel_layout, frames_per_buffer) {
57}
58
59MediaStreamDevice::~MediaStreamDevice() {}
60
61MediaStreamRequest::MediaStreamRequest(
62    int render_process_id,
63    int render_view_id,
64    int page_request_id,
65    const std::string& tab_capture_device_id,
66    const GURL& security_origin,
67    MediaStreamRequestType request_type,
68    const std::string& requested_audio_device_id,
69    const std::string& requested_video_device_id,
70    MediaStreamType audio_type,
71    MediaStreamType video_type)
72    : render_process_id(render_process_id),
73      render_view_id(render_view_id),
74      page_request_id(page_request_id),
75      tab_capture_device_id(tab_capture_device_id),
76      security_origin(security_origin),
77      request_type(request_type),
78      requested_audio_device_id(requested_audio_device_id),
79      requested_video_device_id(requested_video_device_id),
80      audio_type(audio_type),
81      video_type(video_type) {
82}
83
84MediaStreamRequest::~MediaStreamRequest() {}
85
86}  // namespace content
87