1 /* 2 * Copyright 2017 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 SDK_ANDROID_SRC_JNI_PC_MEDIA_STREAM_H_ 12 #define SDK_ANDROID_SRC_JNI_PC_MEDIA_STREAM_H_ 13 14 #include <jni.h> 15 #include <memory> 16 17 #include "api/media_stream_interface.h" 18 #include "pc/media_stream_observer.h" 19 #include "sdk/android/src/jni/jni_helpers.h" 20 21 namespace webrtc { 22 namespace jni { 23 24 class JavaMediaStream : public sigslot::has_slots<> { 25 public: 26 explicit JavaMediaStream( 27 JNIEnv* env, 28 rtc::scoped_refptr<MediaStreamInterface> media_stream); 29 ~JavaMediaStream() override; 30 j_media_stream()31 const ScopedJavaGlobalRef<jobject>& j_media_stream() { 32 return j_media_stream_; 33 } 34 35 private: 36 void OnAudioTrackAddedToStream(AudioTrackInterface* track, 37 MediaStreamInterface* stream); 38 void OnVideoTrackAddedToStream(VideoTrackInterface* track, 39 MediaStreamInterface* stream); 40 void OnAudioTrackRemovedFromStream(AudioTrackInterface* track, 41 MediaStreamInterface* stream); 42 void OnVideoTrackRemovedFromStream(VideoTrackInterface* track, 43 MediaStreamInterface* stream); 44 45 ScopedJavaGlobalRef<jobject> j_media_stream_; 46 std::unique_ptr<MediaStreamObserver> observer_; 47 }; 48 49 jclass GetMediaStreamClass(JNIEnv* env); 50 51 } // namespace jni 52 } // namespace webrtc 53 54 #endif // SDK_ANDROID_SRC_JNI_PC_MEDIA_STREAM_H_ 55