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

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: Changes according to magjed's comments. 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
36 // Not used on Android.
37 // TODO(sakal/magjed): Try to remove this from the interface.
38 void Stop() override { RTC_NOTREACHED(); };
39 // Not used on Android.
40 // TODO(sakal/magjed): Try to remove this from the interface.
41 void Restart() override { RTC_NOTREACHED(); }
42
43 // Currently, none of the Android implementations are screencast.
44 bool is_screencast() const override { return false; }
45
46 // Indicates that the encoder should denoise video before encoding it.
47 // If it is not set, the default configuration is used which is different
48 // depending on video codec.
49 rtc::Optional<bool> needs_denoising() const override {
50 return rtc::Optional<bool>(false);
51 }
52
53 // Returns false if no stats are available, e.g, for a remote
54 // source, or a source which has not seen its first frame yet.
55 // Should avoid blocking.
56 bool GetStats(Stats* stats) override;
57
58 // Called by the native capture observer
59 void SetState(SourceState state);
60
61 SourceState state() const override { return state_; }
62
63 bool remote() const override { return false; }
64
65 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink,
66 const rtc::VideoSinkWants& wants) override;
67 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override;
68
69 void OnByteBufferFrameCaptured(const void* frame_data,
70 int length,
71 int width,
72 int height,
73 int rotation,
74 int64_t timestamp_ns);
75
76 void OnTextureFrameCaptured(int width,
77 int height,
78 int rotation,
79 int64_t timestamp_ns,
80 const webrtc_jni::NativeHandleImpl& handle);
81
82 void OnOutputFormatRequest(int width, int height, int fps);
83
84 rtc::scoped_refptr<webrtc_jni::SurfaceTextureHelper>
85 surface_texture_helper() {
86 return surface_texture_helper_;
87 }
88
89 private:
90 rtc::Thread* signaling_thread_;
91 rtc::AsyncInvoker invoker_;
92 rtc::ThreadChecker worker_thread_checker_;
93 rtc::ThreadChecker camera_thread_checker_;
94 rtc::CriticalSection stats_crit_;
95 rtc::Optional<Stats> stats_ GUARDED_BY(stats_crit_);
96 SourceState state_;
97 rtc::VideoBroadcaster broadcaster_;
98 rtc::TimestampAligner timestamp_aligner_;
99 cricket::VideoAdapter video_adapter_;
100 rtc::CriticalSection apply_rotation_crit_;
101 bool apply_rotation_ GUARDED_BY(apply_rotation_crit_);
102 webrtc::I420BufferPool pre_scale_pool_;
103 webrtc::I420BufferPool post_scale_pool_;
104 rtc::scoped_refptr<webrtc_jni::SurfaceTextureHelper> surface_texture_helper_;
105
106 void OnFrame(const cricket::VideoFrame& frame, int width, int height);
107
108 void OnSinkWantsChanged(const rtc::VideoSinkWants& wants);
109
110 bool AdaptFrame(int width,
111 int height,
112 int64_t camera_time_us,
113 int* out_width,
114 int* out_height,
115 int* crop_width,
116 int* crop_height,
117 int* crop_x,
118 int* crop_y,
119 int64_t* translated_camera_time_us);
120 };
121
122 } // namespace webrtc
123
124 #endif // WEBRTC_API_ANDROIDVIDEOTRACKSOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698