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

Side by Side Diff: webrtc/api/androidvideotracksource.h

Issue 2127893002: AndroidVideoTrackSource implementation (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@magjed-init
Patch Set: Change videoSourceStopped to videoCapturerStopped. Created 4 years, 5 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
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_API_ANDROIDVIDEOTRACKSOURCE_H_
12 #define WEBRTC_API_ANDROIDVIDEOTRACKSOURCE_H_
13
14 #include "webrtc/api/android/jni/native_handle_impl.h"
15 #include "webrtc/api/android/jni/surfacetexturehelper_jni.h"
16 #include "webrtc/api/mediastreaminterface.h"
17 #include "webrtc/api/notifier.h"
18 #include "webrtc/base/asyncinvoker.h"
19 #include "webrtc/base/checks.h"
20 #include "webrtc/base/thread_checker.h"
21 #include "webrtc/base/timestampaligner.h"
22 #include "webrtc/common_video/include/i420_buffer_pool.h"
23 #include "webrtc/media/base/videoadapter.h"
24 #include "webrtc/media/base/videobroadcaster.h"
25 #include "webrtc/media/base/videosinkinterface.h"
26 #include "third_party/libyuv/include/libyuv/convert.h"
27
28 namespace webrtc {
29
30 class AndroidVideoTrackSource : public Notifier<VideoTrackSourceInterface> {
31 public:
32 AndroidVideoTrackSource(rtc::Thread* signaling_thread,
33 JNIEnv* jni,
34 jobject j_egl_context);
35 ~AndroidVideoTrackSource();
36
37 // Not used on Android.
38 // TODO(sakal/magjed): Try to remove this from the interface.
39 void Stop() override { RTC_NOTREACHED(); };
40 // Not used on Android.
41 // TODO(sakal/magjed): Try to remove this from the interface.
42 void Restart() override { RTC_NOTREACHED(); }
43
44 // Currently, none of the Android implementations are screencast.
45 bool is_screencast() const override { return false; }
46
47 // Indicates that the encoder should denoise video before encoding it.
48 // If it is not set, the default configuration is used which is different
49 // depending on video codec.
50 rtc::Optional<bool> needs_denoising() const override {
51 return rtc::Optional<bool>(false);
52 }
53
54 // Returns false if no stats are available, e.g, for a remote
55 // source, or a source which has not seen its first frame yet.
56 // Should avoid blocking.
57 bool GetStats(Stats* stats) override;
58
59 // Called by the native capture observer
60 void SetState(SourceState state);
61
62 SourceState state() const override { return state_; }
63
64 bool remote() const override { return false; }
65
66 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink,
67 const rtc::VideoSinkWants& wants) override;
68 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override;
69
70 void OnFrame(const cricket::VideoFrame& frame, int width, int height);
magjed_webrtc 2016/07/19 12:57:47 Make private.
sakal 2016/07/19 13:46:23 Done.
71
72 void OnByteBufferFrameCaptured(const void* frame_data,
73 int length,
74 int width,
75 int height,
76 int rotation,
77 int64_t timestamp_ns);
78
79 void OnTextureFrameCaptured(int width,
80 int height,
81 int rotation,
82 int64_t timestamp_ns,
83 const webrtc_jni::NativeHandleImpl& handle);
84
85 void OnOutputFormatRequest(int width, int height, int fps);
86
87 rtc::scoped_refptr<webrtc_jni::SurfaceTextureHelper>
88 surface_texture_helper() {
89 return surface_texture_helper_;
90 }
91
92 private:
93 rtc::Thread* signaling_thread_;
94 rtc::AsyncInvoker invoker_;
95 rtc::CriticalSection stats_crit_;
magjed_webrtc 2016/07/19 12:57:47 Move this to the line above stats_.
sakal 2016/07/19 13:46:23 Done.
96 rtc::ThreadChecker worker_thread_checker_;
97 rtc::ThreadChecker camera_thread_checker_;
98 rtc::Optional<Stats> stats_ GUARDED_BY(stats_crit_);
99 SourceState state_;
100 rtc::VideoBroadcaster broadcaster_;
101 rtc::TimestampAligner timestamp_aligner_;
102 cricket::VideoAdapter video_adapter_;
103 bool apply_rotation_;
104 webrtc::I420BufferPool pre_scale_pool_;
105 webrtc::I420BufferPool post_scale_pool_;
106 rtc::scoped_refptr<webrtc_jni::SurfaceTextureHelper> surface_texture_helper_;
107
108 void OnSinkWantsChanged(const rtc::VideoSinkWants& wants);
109
110 bool AdaptFrame(int width,
111 int height,
112 int64_t camera_time_us,
113 int64_t system_time_us,
114 int* out_width,
115 int* out_height,
116 int* crop_width,
117 int* crop_height,
118 int* crop_x,
119 int* crop_y,
120 int64_t* translated_camera_time_us);
121 };
122 }
magjed_webrtc 2016/07/19 12:57:47 nit: Add empty line between }:s and comment "// na
sakal 2016/07/19 13:46:23 Done.
123
124 #endif // WEBRTC_API_ANDROIDVIDEOTRACKSOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698