| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_MEDIA_ANDROID_ROUTER_MEDIA_ROUTER_ANDROID_BRIDGE_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ANDROID_ROUTER_MEDIA_ROUTER_ANDROID_BRIDGE_H_ |
| 7 |
| 8 #include <jni.h> |
| 9 |
| 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/macros.h" |
| 12 #include "chrome/browser/media/router/media_route.h" |
| 13 #include "chrome/browser/media/router/media_sink.h" |
| 14 #include "chrome/browser/media/router/media_source.h" |
| 15 #include "url/origin.h" |
| 16 |
| 17 namespace media_router { |
| 18 |
| 19 class MediaRouterAndroid; |
| 20 |
| 21 // Wraps the JNI layer between MediaRouterAndroid and ChromeMediaRouter. |
| 22 class MediaRouterAndroidBridge { |
| 23 public: |
| 24 explicit MediaRouterAndroidBridge(MediaRouterAndroid* router); |
| 25 ~MediaRouterAndroidBridge(); |
| 26 |
| 27 static bool Register(JNIEnv* env); |
| 28 |
| 29 // Implement the corresponding calls for the MediaRouterAndroid class. |
| 30 // Virtual so could be overridden by tests. |
| 31 virtual void CreateRoute(const MediaSource::Id& source_id, |
| 32 const MediaSink::Id& sink_id, |
| 33 const std::string& presentation_id, |
| 34 const url::Origin& origin, |
| 35 int tab_id, |
| 36 bool is_incognito, |
| 37 int route_request_id); |
| 38 virtual void JoinRoute(const MediaSource::Id& source_id, |
| 39 const std::string& presentation_id, |
| 40 const url::Origin& origin, |
| 41 int tab_id, |
| 42 int route_request_id); |
| 43 virtual void TerminateRoute(const MediaRoute::Id& route_id); |
| 44 virtual void SendRouteMessage(const MediaRoute::Id& route_id, |
| 45 const std::string& message, |
| 46 int callback_id); |
| 47 virtual void DetachRoute(const MediaRoute::Id& route_id); |
| 48 virtual bool StartObservingMediaSinks(const MediaSource::Id& source_id); |
| 49 virtual void StopObservingMediaSinks(const MediaSource::Id& source_id); |
| 50 |
| 51 // Methods called by the Java counterpart. |
| 52 void OnSinksReceived(JNIEnv* env, |
| 53 const base::android::JavaRef<jobject>& obj, |
| 54 const base::android::JavaRef<jstring>& jsource_urn, |
| 55 jint jcount); |
| 56 void OnRouteCreated(JNIEnv* env, |
| 57 const base::android::JavaRef<jobject>& obj, |
| 58 const base::android::JavaRef<jstring>& jmedia_route_id, |
| 59 const base::android::JavaRef<jstring>& jmedia_sink_id, |
| 60 jint jroute_request_id, |
| 61 jboolean jis_local); |
| 62 void OnRouteRequestError(JNIEnv* env, |
| 63 const base::android::JavaRef<jobject>& obj, |
| 64 const base::android::JavaRef<jstring>& jerror_text, |
| 65 jint jroute_request_id); |
| 66 void OnRouteClosed(JNIEnv* env, |
| 67 const base::android::JavaRef<jobject>& obj, |
| 68 const base::android::JavaRef<jstring>& jmedia_route_id); |
| 69 void OnRouteClosedWithError( |
| 70 JNIEnv* env, |
| 71 const base::android::JavaRef<jobject>& obj, |
| 72 const base::android::JavaRef<jstring>& jmedia_route_id, |
| 73 const base::android::JavaRef<jstring>& jmessage); |
| 74 void OnMessageSentResult(JNIEnv* env, |
| 75 const base::android::JavaRef<jobject>& obj, |
| 76 jboolean jsuccess, |
| 77 jint jcallback_id); |
| 78 void OnMessage(JNIEnv* env, |
| 79 const base::android::JavaRef<jobject>& obj, |
| 80 const base::android::JavaRef<jstring>& jmedia_route_id, |
| 81 const base::android::JavaRef<jstring>& jmessage); |
| 82 |
| 83 private: |
| 84 MediaRouterAndroid* native_media_router_; |
| 85 base::android::ScopedJavaGlobalRef<jobject> java_media_router_; |
| 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(MediaRouterAndroidBridge); |
| 88 }; |
| 89 |
| 90 } // namespace media_router |
| 91 |
| 92 #endif // CHROME_BROWSER_MEDIA_ANDROID_ROUTER_MEDIA_ROUTER_ANDROID_BRIDGE_H_ |
| OLD | NEW |