• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "sdk/android/src/jni/pc/media_stream_track.h"
12 
13 #include "api/media_stream_interface.h"
14 #include "sdk/android/generated_peerconnection_jni/MediaStreamTrack_jni.h"
15 #include "sdk/android/native_api/jni/java_types.h"
16 #include "sdk/android/src/jni/jni_helpers.h"
17 
18 namespace webrtc {
19 namespace jni {
20 
NativeToJavaMediaType(JNIEnv * jni,cricket::MediaType media_type)21 ScopedJavaLocalRef<jobject> NativeToJavaMediaType(
22     JNIEnv* jni,
23     cricket::MediaType media_type) {
24   return Java_MediaType_fromNativeIndex(jni, media_type);
25 }
26 
JavaToNativeMediaType(JNIEnv * jni,const JavaRef<jobject> & j_media_type)27 cricket::MediaType JavaToNativeMediaType(JNIEnv* jni,
28                                          const JavaRef<jobject>& j_media_type) {
29   return static_cast<cricket::MediaType>(
30       Java_MediaType_getNative(jni, j_media_type));
31 }
32 
JNI_MediaStreamTrack_GetId(JNIEnv * jni,jlong j_p)33 static ScopedJavaLocalRef<jstring> JNI_MediaStreamTrack_GetId(
34     JNIEnv* jni,
35     jlong j_p) {
36   return NativeToJavaString(
37       jni, reinterpret_cast<MediaStreamTrackInterface*>(j_p)->id());
38 }
39 
JNI_MediaStreamTrack_GetKind(JNIEnv * jni,jlong j_p)40 static ScopedJavaLocalRef<jstring> JNI_MediaStreamTrack_GetKind(
41     JNIEnv* jni,
42     jlong j_p) {
43   return NativeToJavaString(
44       jni, reinterpret_cast<MediaStreamTrackInterface*>(j_p)->kind());
45 }
46 
JNI_MediaStreamTrack_GetEnabled(JNIEnv * jni,jlong j_p)47 static jboolean JNI_MediaStreamTrack_GetEnabled(JNIEnv* jni,
48                                                 jlong j_p) {
49   return reinterpret_cast<MediaStreamTrackInterface*>(j_p)->enabled();
50 }
51 
JNI_MediaStreamTrack_GetState(JNIEnv * jni,jlong j_p)52 static ScopedJavaLocalRef<jobject> JNI_MediaStreamTrack_GetState(
53     JNIEnv* jni,
54     jlong j_p) {
55   return Java_State_fromNativeIndex(
56       jni, reinterpret_cast<MediaStreamTrackInterface*>(j_p)->state());
57 }
58 
JNI_MediaStreamTrack_SetEnabled(JNIEnv * jni,jlong j_p,jboolean enabled)59 static jboolean JNI_MediaStreamTrack_SetEnabled(JNIEnv* jni,
60                                                 jlong j_p,
61                                                 jboolean enabled) {
62   return reinterpret_cast<MediaStreamTrackInterface*>(j_p)->set_enabled(
63       enabled);
64 }
65 
66 }  // namespace jni
67 }  // namespace webrtc
68