
Reason for revert: Issues fixed Original issue's description: > Revert of Combine webrtc/api/java/android and webrtc/api/java/src. (patchset #1 id:1 of https://codereview.webrtc.org/2111823002/ ) > > Reason for revert: > Breaks downstream dependencies > > Original issue's description: > > Combine webrtc/api/java/android and webrtc/api/java/src. > > > > It used to be that there was a Java api for devices not running Android > > but that is no longer the case. I combined the directories and made > > the folder structure chromium style. > > > > BUG=webrtc:6067 > > R=magjed@webrtc.org, tommi@webrtc.org > > > > Committed:ceefe20dd6
> > TBR=magjed@webrtc.org,tommi@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6067 > > Committed:9b0dc622d4
TBR=magjed@webrtc.org,tommi@webrtc.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:6067 Review-Url: https://codereview.webrtc.org/2111923003 Cr-Commit-Position: refs/heads/master@{#13363}
94 lines
2.9 KiB
C++
94 lines
2.9 KiB
C++
/*
|
|
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include "webrtc/api/androidvideocapturer.h"
|
|
|
|
#include <memory>
|
|
|
|
#include "webrtc/api/android/jni/native_handle_impl.h"
|
|
#include "webrtc/base/common.h"
|
|
#include "webrtc/base/timeutils.h"
|
|
#include "webrtc/media/engine/webrtcvideoframe.h"
|
|
|
|
namespace webrtc {
|
|
|
|
AndroidVideoCapturer::AndroidVideoCapturer(
|
|
const rtc::scoped_refptr<AndroidVideoCapturerDelegate>& delegate)
|
|
: running_(false),
|
|
delegate_(delegate) {
|
|
thread_checker_.DetachFromThread();
|
|
SetSupportedFormats(delegate_->GetSupportedFormats());
|
|
}
|
|
|
|
AndroidVideoCapturer::~AndroidVideoCapturer() {
|
|
RTC_CHECK(!running_);
|
|
}
|
|
|
|
cricket::CaptureState AndroidVideoCapturer::Start(
|
|
const cricket::VideoFormat& capture_format) {
|
|
RTC_CHECK(thread_checker_.CalledOnValidThread());
|
|
RTC_CHECK(!running_);
|
|
const int fps = cricket::VideoFormat::IntervalToFps(capture_format.interval);
|
|
LOG(LS_INFO) << " AndroidVideoCapturer::Start " << capture_format.width << "x"
|
|
<< capture_format.height << "@" << fps;
|
|
|
|
running_ = true;
|
|
delegate_->Start(capture_format.width, capture_format.height, fps, this);
|
|
SetCaptureFormat(&capture_format);
|
|
return cricket::CS_STARTING;
|
|
}
|
|
|
|
void AndroidVideoCapturer::Stop() {
|
|
LOG(LS_INFO) << " AndroidVideoCapturer::Stop ";
|
|
RTC_CHECK(thread_checker_.CalledOnValidThread());
|
|
RTC_CHECK(running_);
|
|
running_ = false;
|
|
SetCaptureFormat(NULL);
|
|
|
|
delegate_->Stop();
|
|
SetCaptureState(cricket::CS_STOPPED);
|
|
}
|
|
|
|
bool AndroidVideoCapturer::IsRunning() {
|
|
RTC_CHECK(thread_checker_.CalledOnValidThread());
|
|
return running_;
|
|
}
|
|
|
|
bool AndroidVideoCapturer::GetPreferredFourccs(std::vector<uint32_t>* fourccs) {
|
|
RTC_CHECK(thread_checker_.CalledOnValidThread());
|
|
fourccs->push_back(cricket::FOURCC_YV12);
|
|
return true;
|
|
}
|
|
|
|
void AndroidVideoCapturer::OnCapturerStarted(bool success) {
|
|
RTC_CHECK(thread_checker_.CalledOnValidThread());
|
|
const cricket::CaptureState new_state =
|
|
success ? cricket::CS_RUNNING : cricket::CS_FAILED;
|
|
SetCaptureState(new_state);
|
|
}
|
|
|
|
void AndroidVideoCapturer::OnOutputFormatRequest(
|
|
int width, int height, int fps) {
|
|
RTC_CHECK(thread_checker_.CalledOnValidThread());
|
|
cricket::VideoFormat format(width, height,
|
|
cricket::VideoFormat::FpsToInterval(fps), 0);
|
|
video_adapter()->OnOutputFormatRequest(format);
|
|
}
|
|
|
|
bool AndroidVideoCapturer::GetBestCaptureFormat(
|
|
const cricket::VideoFormat& desired,
|
|
cricket::VideoFormat* best_format) {
|
|
// Delegate this choice to VideoCapturer.startCapture().
|
|
*best_format = desired;
|
|
return true;
|
|
}
|
|
|
|
} // namespace webrtc
|