-
Notifications
You must be signed in to change notification settings - Fork 62
Dash factory fix #1251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Dash factory fix #1251
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c34f5cd
[add] Enhance DashMediaSource and TrackGroupArray with fluent API and…
ne0rrmatrix a389493
Merge branch 'dotnet:main' into DashFactoryFix
ne0rrmatrix 64d9d26
[add] Implement Tracks class with methods for accessing track groups …
ne0rrmatrix 97f2744
Fixes
ne0rrmatrix 487d9cb
[remove] Remove GetGroup method from TrackGroupArray for consistency …
ne0rrmatrix c70bc86
Merge branch 'dotnet:main' into DashFactoryFix
ne0rrmatrix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Java.Interop; | ||
using Android.Runtime; | ||
|
||
namespace AndroidX.Media3.Common; | ||
|
||
// Convenience additions to make the modern Media3 Tracks API usable following API guidelines. | ||
// Enables: player.getCurrentTracks().getGroups() and iteration over track groups. | ||
public partial class Tracks : System.Collections.Generic.IEnumerable<Tracks.Group> | ||
{ | ||
/// <summary> | ||
/// Gets an immutable list of track groups. | ||
/// This implements the missing getGroups() method from the Java API. | ||
/// </summary> | ||
/// <returns>An immutable list of track groups.</returns> | ||
/// <remarks> | ||
/// This method provides access to the track groups, where each group contains tracks that | ||
/// present the same content but in different formats (different qualities, codecs, languages, etc.). | ||
/// | ||
/// This matches the Java API: public ImmutableList<Tracks.Group> getGroups() | ||
/// </remarks> | ||
public unsafe IList<Tracks.Group>? GetGroups() | ||
{ | ||
// Call the native Java getGroups() method | ||
// Based on the AndroidX Media3 documentation, this should return ImmutableList<Group> | ||
const string __id = "getGroups.()Lcom/google/common/collect/ImmutableList;"; | ||
try | ||
{ | ||
var __rm = _members.InstanceMethods.InvokeNonvirtualObjectMethod(__id, this, null); | ||
return global::Android.Runtime.JavaList<Tracks.Group>.FromJniHandle(__rm.Handle, JniHandleOwnership.TransferLocalRef); | ||
} | ||
finally | ||
{ | ||
global::System.GC.KeepAlive(this); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the track group at the specified index. | ||
/// This method provides access to individual track groups within the Tracks collection. | ||
/// </summary> | ||
/// <param name="index">The index of the group to retrieve.</param> | ||
/// <returns>The track group at the specified index.</returns> | ||
/// <remarks> | ||
/// Each group contains tracks that present the same content but in different formats | ||
/// (different qualities, codecs, languages, etc.). | ||
/// </remarks> | ||
public Tracks.Group? GetGroup(int index) | ||
{ | ||
var groups = GetGroups(); | ||
if (groups == null || index < 0 || index >= groups.Count) | ||
return null; | ||
|
||
return groups[index]; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the track group at the specified index using indexer syntax. | ||
/// </summary> | ||
/// <param name="index">The index of the group to retrieve.</param> | ||
/// <returns>The track group at the specified index.</returns> | ||
public Tracks.Group? this[int index] => GetGroup(index); | ||
|
||
/// <summary> | ||
/// Gets the number of track groups. | ||
/// </summary> | ||
public int Count | ||
{ | ||
get | ||
{ | ||
var groups = GetGroups(); | ||
return groups?.Count ?? 0; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Returns an enumerator that iterates through the track groups. | ||
/// </summary> | ||
/// <returns>An enumerator for the track groups.</returns> | ||
public IEnumerator<Tracks.Group> GetEnumerator() | ||
{ | ||
var groups = GetGroups(); | ||
if (groups == null) | ||
return Enumerable.Empty<Tracks.Group>().GetEnumerator(); | ||
|
||
return groups.GetEnumerator(); | ||
} | ||
|
||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
source/androidx.media3/media3-exoplayer-dash/Additions/DashMediaSource.Factory.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using AndroidX.Media3.ExoPlayer.Drm; | ||
using AndroidX.Media3.ExoPlayer.Source; | ||
using AndroidX.Media3.ExoPlayer.Upstream; | ||
|
||
namespace AndroidX.Media3.ExoPlayer.Dash | ||
{ | ||
public sealed partial class DashMediaSource | ||
{ | ||
public sealed partial class Factory | ||
{ | ||
// Extension methods for fluent API chaining with concrete return type | ||
public Factory SetDrmSessionManagerProviderFluent(IDrmSessionManagerProvider? drmSessionManagerProvider) | ||
{ | ||
SetDrmSessionManagerProvider(drmSessionManagerProvider); | ||
return this; | ||
} | ||
|
||
public Factory SetLoadErrorHandlingPolicyFluent(ILoadErrorHandlingPolicy? loadErrorHandlingPolicy) | ||
{ | ||
SetLoadErrorHandlingPolicy(loadErrorHandlingPolicy); | ||
return this; | ||
} | ||
} | ||
} | ||
|
||
public static class DashMediaSourceFactoryExtensions | ||
{ | ||
/// <summary> | ||
/// Sets the DRM session manager provider and returns the Factory for fluent chaining. | ||
/// </summary> | ||
public static DashMediaSource.Factory SetDrmSessionManagerProviderChained(this DashMediaSource.Factory factory, IDrmSessionManagerProvider? provider) | ||
{ | ||
factory.SetDrmSessionManagerProvider(provider); | ||
return factory; | ||
} | ||
|
||
/// <summary> | ||
/// Sets the load error handling policy and returns the Factory for fluent chaining. | ||
/// </summary> | ||
public static DashMediaSource.Factory SetLoadErrorHandlingPolicyChained(this DashMediaSource.Factory factory, ILoadErrorHandlingPolicy? policy) | ||
{ | ||
factory.SetLoadErrorHandlingPolicy(policy); | ||
return factory; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
source/androidx.media3/media3-exoplayer/Additions/TrackGroupArray.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using AndroidX.Media3.Common; | ||
|
||
namespace AndroidX.Media3.ExoPlayer.Source; | ||
|
||
// Convenience additions to match common ExoPlayer Java samples (trackGroups.get(i)) | ||
// and the intuitive GetGroup(...) naming some developers attempt to use. | ||
public partial class TrackGroupArray | ||
{ | ||
|
||
// Indexer for more idiomatic C# access: trackGroups[i] | ||
public TrackGroup? this[int index] => Get(index); | ||
} |
23 changes: 23 additions & 0 deletions
23
source/androidx.media3/media3-exoplayer/Additions/TrackSelectionArray.additions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Additions to improve .NET ergonomics for TrackSelectionArray | ||
// Provides indexer and IEnumerable implementation for iterating track selections. | ||
|
||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
namespace AndroidX.Media3.ExoPlayer.TrackSelection | ||
{ | ||
public partial class TrackSelectionArray : IEnumerable<ITrackSelection?> | ||
{ | ||
public ITrackSelection? this[int index] => Get(index); | ||
|
||
public IEnumerator<ITrackSelection?> GetEnumerator() | ||
{ | ||
for (int i = 0; i < Length; i++) | ||
{ | ||
yield return Get(i); | ||
} | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.