• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * libjingle
3  * Copyright 2013 Google Inc.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  *  1. Redistributions of source code must retain the above copyright notice,
9  *     this list of conditions and the following disclaimer.
10  *  2. Redistributions in binary form must reproduce the above copyright notice,
11  *     this list of conditions and the following disclaimer in the documentation
12  *     and/or other materials provided with the distribution.
13  *  3. The name of the author may not be used to endorse or promote products
14  *     derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include "talk/app/webrtc/remotevideocapturer.h"
29 
30 #include "talk/media/base/videoframe.h"
31 #include "webrtc/base/logging.h"
32 
33 namespace webrtc {
34 
RemoteVideoCapturer()35 RemoteVideoCapturer::RemoteVideoCapturer() {}
36 
~RemoteVideoCapturer()37 RemoteVideoCapturer::~RemoteVideoCapturer() {}
38 
Start(const cricket::VideoFormat & capture_format)39 cricket::CaptureState RemoteVideoCapturer::Start(
40     const cricket::VideoFormat& capture_format) {
41   if (capture_state() == cricket::CS_RUNNING) {
42     LOG(LS_WARNING)
43         << "RemoteVideoCapturer::Start called when it's already started.";
44     return capture_state();
45   }
46 
47   LOG(LS_INFO) << "RemoteVideoCapturer::Start";
48   SetCaptureFormat(&capture_format);
49   return cricket::CS_RUNNING;
50 }
51 
Stop()52 void RemoteVideoCapturer::Stop() {
53   if (capture_state() == cricket::CS_STOPPED) {
54     LOG(LS_WARNING)
55         << "RemoteVideoCapturer::Stop called when it's already stopped.";
56     return;
57   }
58 
59   LOG(LS_INFO) << "RemoteVideoCapturer::Stop";
60   SetCaptureFormat(NULL);
61   SetCaptureState(cricket::CS_STOPPED);
62 }
63 
IsRunning()64 bool RemoteVideoCapturer::IsRunning() {
65   return capture_state() == cricket::CS_RUNNING;
66 }
67 
GetPreferredFourccs(std::vector<uint32_t> * fourccs)68 bool RemoteVideoCapturer::GetPreferredFourccs(std::vector<uint32_t>* fourccs) {
69   if (!fourccs)
70     return false;
71   fourccs->push_back(cricket::FOURCC_I420);
72   return true;
73 }
74 
GetBestCaptureFormat(const cricket::VideoFormat & desired,cricket::VideoFormat * best_format)75 bool RemoteVideoCapturer::GetBestCaptureFormat(
76     const cricket::VideoFormat& desired, cricket::VideoFormat* best_format) {
77   if (!best_format) {
78     return false;
79   }
80 
81   // RemoteVideoCapturer does not support capability enumeration.
82   // Use the desired format as the best format.
83   best_format->width = desired.width;
84   best_format->height = desired.height;
85   best_format->fourcc = cricket::FOURCC_I420;
86   best_format->interval = desired.interval;
87   return true;
88 }
89 
IsScreencast() const90 bool RemoteVideoCapturer::IsScreencast() const {
91   // TODO(ronghuawu): what about remote screencast stream.
92   return false;
93 }
94 
95 }  // namespace webrtc
96