From 784189c1a0597661859759f059ab9fcdc666ab7a Mon Sep 17 00:00:00 2001 From: cobalt-github-releaser-bot <95661244+cobalt-github-releaser-bot@users.noreply.github.com> Date: Fri, 16 Aug 2024 19:50:01 -0700 Subject: [PATCH] Cherry pick PR #3988: [android] Move files in dev/cobalt/media to .../coat (#4003) Refer to the original PR: https://github.com/youtube/cobalt/pull/3988 Move platform related source code (e.g. CaptionSettings.java, CobaltMediaSession.java) from dev/cobalt/media to dev/cobalt/coat. There are no functional changes otherwise. Some features are mostly used during video playback, like the MediaSession where the playback control and status is displayed during playback, are really platform features. Their implementations were placed in the media/ folder due to legacy reasons. This PR move them back to the coat folder, where other platform implementations stay. b/345542000 --------- Co-authored-by: xiaomings --- starboard/android/apk/apk_sources.gni | 12 ++++++------ .../src/app/java/dev/cobalt/app/MainActivity.java | 2 +- .../cobalt/{media => coat}/ArtworkDownloader.java | 2 +- .../{media => coat}/ArtworkDownloaderDefault.java | 4 ++-- .../dev/cobalt/{media => coat}/ArtworkLoader.java | 2 +- .../dev/cobalt/{media => coat}/CaptionSettings.java | 2 +- .../cobalt/{media => coat}/CobaltMediaSession.java | 6 +++--- .../java/dev/cobalt/{media => coat}/MediaImage.java | 2 +- .../main/java/dev/cobalt/coat/StarboardBridge.java | 4 ---- .../java/dev/cobalt/media/AudioOutputManager.java | 1 + .../shared/accessibility_get_caption_settings.cc | 2 +- .../android/shared/android_media_session_client.cc | 12 ++++++------ 12 files changed, 24 insertions(+), 27 deletions(-) rename starboard/android/apk/app/src/main/java/dev/cobalt/{media => coat}/ArtworkDownloader.java (96%) rename starboard/android/apk/app/src/main/java/dev/cobalt/{media => coat}/ArtworkDownloaderDefault.java (96%) rename starboard/android/apk/app/src/main/java/dev/cobalt/{media => coat}/ArtworkLoader.java (99%) rename starboard/android/apk/app/src/main/java/dev/cobalt/{media => coat}/CaptionSettings.java (98%) rename starboard/android/apk/app/src/main/java/dev/cobalt/{media => coat}/CobaltMediaSession.java (99%) rename starboard/android/apk/app/src/main/java/dev/cobalt/{media => coat}/MediaImage.java (97%) diff --git a/starboard/android/apk/apk_sources.gni b/starboard/android/apk/apk_sources.gni index f57313452247..595bfba60447 100644 --- a/starboard/android/apk/apk_sources.gni +++ b/starboard/android/apk/apk_sources.gni @@ -18,10 +18,15 @@ apk_sources = [ "//starboard/android/apk/app/src/app/java/dev/cobalt/app/CobaltApplication.java", "//starboard/android/apk/app/src/app/java/dev/cobalt/app/MainActivity.java", + "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkDownloader.java", + "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkDownloaderDefault.java", + "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkLoader.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/AudioPermissionRequester.java", + "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CaptionSettings.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltA11yHelper.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltActivity.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltHttpHelper.java", + "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltMediaSession.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltService.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltSystemConfigChangeReceiver.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltTextToSpeechHelper.java", @@ -30,6 +35,7 @@ apk_sources = [ "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/KeyboardEditor.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/KeyboardInputConnection.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/MediaPlaybackService.java", + "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/MediaImage.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/NetworkStatus.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/NullCobaltFactory.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/PlatformError.java", @@ -37,19 +43,13 @@ apk_sources = [ "//starboard/android/apk/app/src/main/java/dev/cobalt/coat/StarboardBridge.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/libraries/services/clientloginfo/ClientLogInfo.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/libraries/services/clientloginfo/ClientLogInfoModule.java", - "//starboard/android/apk/app/src/main/java/dev/cobalt/media/ArtworkDownloader.java", - "//starboard/android/apk/app/src/main/java/dev/cobalt/media/ArtworkDownloaderDefault.java", - "//starboard/android/apk/app/src/main/java/dev/cobalt/media/ArtworkLoader.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/AudioOutputManager.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/AudioTrackBridge.java", - "//starboard/android/apk/app/src/main/java/dev/cobalt/media/CaptionSettings.java", - "//starboard/android/apk/app/src/main/java/dev/cobalt/media/CobaltMediaSession.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/Log.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecBridge.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecCapabilitiesLogger.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecUtil.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaDrmBridge.java", - "//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaImage.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/VideoFrameReleaseTimeHelper.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/VideoSurfaceTexture.java", "//starboard/android/apk/app/src/main/java/dev/cobalt/media/VideoSurfaceView.java", diff --git a/starboard/android/apk/app/src/app/java/dev/cobalt/app/MainActivity.java b/starboard/android/apk/app/src/app/java/dev/cobalt/app/MainActivity.java index 680eb4674dd0..20fbcdf4b4a9 100644 --- a/starboard/android/apk/app/src/app/java/dev/cobalt/app/MainActivity.java +++ b/starboard/android/apk/app/src/app/java/dev/cobalt/app/MainActivity.java @@ -16,11 +16,11 @@ import android.app.Activity; import android.app.Service; +import dev.cobalt.coat.ArtworkDownloaderDefault; import dev.cobalt.coat.CobaltActivity; import dev.cobalt.coat.CobaltService; import dev.cobalt.coat.StarboardBridge; import dev.cobalt.libraries.services.clientloginfo.ClientLogInfoModule; -import dev.cobalt.media.ArtworkDownloaderDefault; import dev.cobalt.util.Holder; /** diff --git a/starboard/android/apk/app/src/main/java/dev/cobalt/media/ArtworkDownloader.java b/starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkDownloader.java similarity index 96% rename from starboard/android/apk/app/src/main/java/dev/cobalt/media/ArtworkDownloader.java rename to starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkDownloader.java index 7bb294d3c025..6b2f0132b165 100644 --- a/starboard/android/apk/app/src/main/java/dev/cobalt/media/ArtworkDownloader.java +++ b/starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkDownloader.java @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package dev.cobalt.media; +package dev.cobalt.coat; /** * Interface to download artwork (Bitmap) from a URL, intended for use in media session metadata. diff --git a/starboard/android/apk/app/src/main/java/dev/cobalt/media/ArtworkDownloaderDefault.java b/starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkDownloaderDefault.java similarity index 96% rename from starboard/android/apk/app/src/main/java/dev/cobalt/media/ArtworkDownloaderDefault.java rename to starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkDownloaderDefault.java index 8cc99c22a1a8..023ec05ce6eb 100644 --- a/starboard/android/apk/app/src/main/java/dev/cobalt/media/ArtworkDownloaderDefault.java +++ b/starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkDownloaderDefault.java @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -package dev.cobalt.media; +package dev.cobalt.coat; -import static dev.cobalt.media.Log.TAG; +import static dev.cobalt.util.Log.TAG; import android.graphics.Bitmap; import android.graphics.BitmapFactory; diff --git a/starboard/android/apk/app/src/main/java/dev/cobalt/media/ArtworkLoader.java b/starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkLoader.java similarity index 99% rename from starboard/android/apk/app/src/main/java/dev/cobalt/media/ArtworkLoader.java rename to starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkLoader.java index 1742a435fe37..c2c52b9f928f 100644 --- a/starboard/android/apk/app/src/main/java/dev/cobalt/media/ArtworkLoader.java +++ b/starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkLoader.java @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package dev.cobalt.media; +package dev.cobalt.coat; import android.graphics.Bitmap; import android.os.Handler; diff --git a/starboard/android/apk/app/src/main/java/dev/cobalt/media/CaptionSettings.java b/starboard/android/apk/app/src/main/java/dev/cobalt/coat/CaptionSettings.java similarity index 98% rename from starboard/android/apk/app/src/main/java/dev/cobalt/media/CaptionSettings.java rename to starboard/android/apk/app/src/main/java/dev/cobalt/coat/CaptionSettings.java index 43d69976c274..7dfa7ddae0af 100644 --- a/starboard/android/apk/app/src/main/java/dev/cobalt/media/CaptionSettings.java +++ b/starboard/android/apk/app/src/main/java/dev/cobalt/coat/CaptionSettings.java @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package dev.cobalt.media; +package dev.cobalt.coat; import android.view.accessibility.CaptioningManager; import dev.cobalt.util.UsedByNative; diff --git a/starboard/android/apk/app/src/main/java/dev/cobalt/media/CobaltMediaSession.java b/starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltMediaSession.java similarity index 99% rename from starboard/android/apk/app/src/main/java/dev/cobalt/media/CobaltMediaSession.java rename to starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltMediaSession.java index e3541b56f989..c10d19798cb1 100644 --- a/starboard/android/apk/app/src/main/java/dev/cobalt/media/CobaltMediaSession.java +++ b/starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltMediaSession.java @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -package dev.cobalt.media; +package dev.cobalt.coat; -import static dev.cobalt.media.Log.TAG; +import static dev.cobalt.util.Log.TAG; import android.app.Activity; import android.content.Context; @@ -50,7 +50,7 @@ public class CobaltMediaSession private AudioFocusRequest audioFocusRequest; - interface UpdateVolumeListener { + public interface UpdateVolumeListener { /** Called when there is a change in audio focus. */ void onUpdateVolume(float gain); } diff --git a/starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaImage.java b/starboard/android/apk/app/src/main/java/dev/cobalt/coat/MediaImage.java similarity index 97% rename from starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaImage.java rename to starboard/android/apk/app/src/main/java/dev/cobalt/coat/MediaImage.java index 899dc224ab2b..70322593b8da 100644 --- a/starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaImage.java +++ b/starboard/android/apk/app/src/main/java/dev/cobalt/coat/MediaImage.java @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package dev.cobalt.media; +package dev.cobalt.coat; import dev.cobalt.util.UsedByNative; diff --git a/starboard/android/apk/app/src/main/java/dev/cobalt/coat/StarboardBridge.java b/starboard/android/apk/app/src/main/java/dev/cobalt/coat/StarboardBridge.java index 59812a7f14d2..6a70410bddca 100644 --- a/starboard/android/apk/app/src/main/java/dev/cobalt/coat/StarboardBridge.java +++ b/starboard/android/apk/app/src/main/java/dev/cobalt/coat/StarboardBridge.java @@ -40,11 +40,7 @@ import android.view.accessibility.AccessibilityManager; import android.view.accessibility.CaptioningManager; import androidx.annotation.Nullable; -import dev.cobalt.media.ArtworkDownloader; import dev.cobalt.media.AudioOutputManager; -import dev.cobalt.media.CaptionSettings; -import dev.cobalt.media.CobaltMediaSession; -import dev.cobalt.media.MediaImage; import dev.cobalt.util.DisplayUtil; import dev.cobalt.util.Holder; import dev.cobalt.util.Log; diff --git a/starboard/android/apk/app/src/main/java/dev/cobalt/media/AudioOutputManager.java b/starboard/android/apk/app/src/main/java/dev/cobalt/media/AudioOutputManager.java index 9aba9c3ab797..13fdf700a525 100644 --- a/starboard/android/apk/app/src/main/java/dev/cobalt/media/AudioOutputManager.java +++ b/starboard/android/apk/app/src/main/java/dev/cobalt/media/AudioOutputManager.java @@ -25,6 +25,7 @@ import android.media.AudioTrack; import android.os.Build; import androidx.annotation.RequiresApi; +import dev.cobalt.coat.CobaltMediaSession; import dev.cobalt.util.Log; import dev.cobalt.util.UsedByNative; import java.util.ArrayList; diff --git a/starboard/android/shared/accessibility_get_caption_settings.cc b/starboard/android/shared/accessibility_get_caption_settings.cc index aef7535d5732..2d06a7991c2c 100644 --- a/starboard/android/shared/accessibility_get_caption_settings.cc +++ b/starboard/android/shared/accessibility_get_caption_settings.cc @@ -113,7 +113,7 @@ bool SbAccessibilityGetCaptionSettings( ScopedLocalJavaRef j_caption_settings( env->CallStarboardObjectMethodOrAbort( - "getCaptionSettings", "()Ldev/cobalt/media/CaptionSettings;")); + "getCaptionSettings", "()Ldev/cobalt/coat/CaptionSettings;")); jfloat font_scale = env->GetFloatFieldOrAbort(j_caption_settings.Get(), "fontScale", "F"); diff --git a/starboard/android/shared/android_media_session_client.cc b/starboard/android/shared/android_media_session_client.cc index e031ad1178f0..208c1abf951e 100644 --- a/starboard/android/shared/android_media_session_client.cc +++ b/starboard/android/shared/android_media_session_client.cc @@ -191,7 +191,7 @@ void OnMediaSessionStateChanged( if (artwork_count > 0) { CobaltExtensionMediaImage* artwork(media_metadata->artwork); ScopedLocalJavaRef media_image_class( - env->FindClassExtOrAbort("dev/cobalt/media/MediaImage")); + env->FindClassExtOrAbort("dev/cobalt/coat/MediaImage")); jmethodID media_image_constructor = env->GetMethodID( media_image_class.Get(), "", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); @@ -234,7 +234,7 @@ void OnMediaSessionStateChanged( env->CallStarboardVoidMethodOrAbort( "updateMediaSession", "(IJJFLjava/lang/String;Ljava/lang/String;Ljava/lang/String;" - "[Ldev/cobalt/media/MediaImage;J)V", + "[Ldev/cobalt/coat/MediaImage;J)V", playback_state, playback_state_actions, session_state.current_playback_position / kSbTimeMillisecond, static_cast(session_state.actual_playback_rate), j_title.Get(), @@ -290,9 +290,9 @@ const void* GetMediaSessionApi() { } // namespace starboard extern "C" SB_EXPORT_PLATFORM void -Java_dev_cobalt_media_CobaltMediaSession_nativeInvokeAction(JNIEnv* env, - jclass unused_clazz, - jlong action, - jlong seek_ms) { +Java_dev_cobalt_coat_CobaltMediaSession_nativeInvokeAction(JNIEnv* env, + jclass unused_clazz, + jlong action, + jlong seek_ms) { starboard::android::shared::NativeInvokeAction(action, seek_ms); }