androidx / androidx/media

Possibility to tell to Media3's RtpOpusReader.java to consider log-session-id in AMessage as id?

Open
#859 8 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

bad media
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

Hello everyone!

I am trying to play a RTSP audio stream in my Java App which codec is audio/opus using media3 exoplayer 1.2.0
If I try to play , it goes normally with this error:

LoadTask                E  Unexpected exception loading stream
                             java.lang.IllegalArgumentException: ID Header missing
                                 at androidx.media3.common.util.Assertions.checkArgument(Assertions.java:55)
                                 at androidx.media3.exoplayer.rtsp.reader.RtpOpusReader.validateOpusIdHeader(RtpOpusReader.java:146)
                                 at androidx.media3.exoplayer.rtsp.reader.RtpOpusReader.consume(RtpOpusReader.java:90)
                                 at androidx.media3.exoplayer.rtsp.RtpExtractor.read(RtpExtractor.java:178)
                                 at androidx.media3.exoplayer.rtsp.RtpDataLoadable.load(RtpDataLoadable.java:177)
                                 at androidx.media3.exoplayer.upstream.Loader$LoadTask.run(Loader.java:417)
                                 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                 at java.lang.Thread.run(Thread.java:1012)
ExoPlayerImplInternal   E  Playback error
                             androidx.media3.exoplayer.ExoPlaybackException: Source error

but if I look in LogCat about stream analyzing I see :

EventLogger             D  state [eventTime=5.47, mediaPos=0.00, window=0, period=0, BUFFERING]
EventLogger             D  loading [eventTime=6.49, mediaPos=0.00, window=0, period=0, true]
EventLogger             D  timeline [eventTime=6.49, mediaPos=0.00, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE
EventLogger             D    period [?]
EventLogger             D    window [?, seekable=false, dynamic=false]
EventLogger             D  ]
BufferPoolAccessor2.0   D  evictor expired: 1, evicted: 0
TrafficStats            D  tagSocket(112) with statsTag=0xffffffff, statsUid=-1
TrafficStats            D  tagSocket(138) with statsTag=0xffffffff, statsUid=-1
DMCodecAdapterFactory   I  Creating an asynchronous MediaCodec adapter for track type audio
EventLogger             D  audioEnabled [eventTime=7.11, mediaPos=0.00, window=0, period=0]
MediaCodec              I  (0xb400007977f10fb0) init name(c2.android.opus.decoder)
CCodec                  D  allocate(c2.android.opus.decoder)
EventLogger             D  tracks [eventTime=7.11, mediaPos=0.00, window=0, period=0
EventLogger             D    group [
EventLogger             D      [X] Track:0, id=null, mimeType=audio/opus, channels=2, sample_rate=48000, supported=YES
EventLogger             D    ]
EventLogger             D  ]
CCodec                  I  setting up 'default' as default (vendor) store
CCodec                  I  Created component [c2.android.opus.decoder]
CCodecConfig            D  read media type: audio/opus
ReflectedParamUpdater   D  extent() != 1 for single value type: algo.buffers.max-count.values
ReflectedParamUpdater   D  extent() != 1 for single value type: output.subscribed-indices.values
ReflectedParamUpdater   D  extent() != 1 for single value type: input.buffers.allocator-ids.values
ReflectedParamUpdater   D  extent() != 1 for single value type: output.buffers.allocator-ids.values
ReflectedParamUpdater   D  extent() != 1 for single value type: algo.buffers.allocator-ids.values
ReflectedParamUpdater   D  extent() != 1 for single value type: output.buffers.pool-ids.values
ReflectedParamUpdater   D  extent() != 1 for single value type: algo.buffers.pool-ids.values
CCodecConfig            I  query failed after returning 7 values (BAD_INDEX)
CCodecConfig            D  c2 config diff is Dict {
                             c2::u32 coded.bitrate.value = 6000
                             c2::u32 input.buffers.max-size.value = 5760
                             c2::u32 input.delay.value = 0
                             string input.media-type.value = "audio/opus"
                             string output.media-type.value = "audio/raw"
                             c2::u32 raw.channel-count.value = 1
                             c2::u32 raw.sample-rate.value = 48000
                           }
MediaCodec              I  (0xb400007977f10fb0) Component Allocated (c2.android.opus.decoder)
MediaCodec              I  MediaCodec will operate in async mode
MediaCodec              I  (0xb400007977f10fb0) configure surface(0x0) crypto(0x0) flags(0)
MediaCodec              D  (0xb400007977f10fb0) configure format: AMessage(what = 0x00000000) = {
                                                                      float operating-rate = 48000.000000
                                                                      string log-session-id = "6T6xOhZNtcDfmPN0"
                                                                      int32_t sample-rate = 48000
                                                                      string mime = "audio/opus"
                                                                      int32_t channel-count = 2
                                                                      int32_t priority = 0
                                 int32_t max-output-channel-count = 99
                               }
MediaCodec              D  flushMediametrics
CCodec                  D  [c2.android.opus.decoder] buffers are bound to CCodec for this session
CCodecConfig            D  no c2 equivalents for log-session-id
CCodecConfig            D  no c2 equivalents for flags
CCodecConfig            D  c2 config diff is   c2::u32 raw.channel-count.value = 2
Codec2Client            W  query -- param skipped: index = 1107298332.
CCodec                  D  encoding statistics level = 0
CCodec                  D  setup formats input: AMessage(what = 0x00000000) = {
                             int32_t bitrate = 6000
                             int32_t channel-count = 2
                             int32_t max-input-size = 5760
                             string mime = "audio/opus"
                             int32_t sample-rate = 48000
                           }
CCodec                  D  setup formats output: AMessage(what = 0x00000000) = {
                             int32_t channel-count = 2
                             string mime = "audio/raw"
                             int32_t sample-rate = 48000
                             int32_t android._config-pcm-encoding = 2
                           }
CCodecConfig            I  query failed after returning 7 values (BAD_INDEX)
MediaCodec              I  (0xb400007977f10fb0) start
MediaCodec              D  keep callback message for reclaim
Codec2Client            W  query -- param skipped: index = 1342179345.
Codec2Client            W  query -- param skipped: index = 2415921170.
CCodecBufferChannel     D  [c2.android.opus.decoder#215] Created input block pool with allocatorID 16 => poolID 18 - OK (0)
CCodecBufferChannel     I  [c2.android.opus.decoder#215] Created output block pool with allocatorID 16 => poolID 1428 - OK
CCodecBufferChannel     D  [c2.android.opus.decoder#215] Configured output block pool ids 1428 => OK
CCodecBufferChannel     D  [c2.android.opus.decoder#215] start: updating output delay 0
MediaCodec              I  (0xb400007977f10fb0) kWhatStartCompleted
EventLogger             D  audioDecoderInitialized [eventTime=7.13, mediaPos=0.00, window=0, period=0, c2.android.opus.decoder]
EventLogger             D  audioInputFormat [eventTime=7.13, mediaPos=0.00, window=0, period=0, id=null, mimeType=audio/opus, channels=2, sample_rate=48000]

where audioInputFormat returns just in fact id=null

audioInputFormat [eventTime=7.13, mediaPos=0.00, window=0, period=0, id=null, mimeType=audio/opus, channels=2, sample_rate=48000]

but looking better in the messages of stream I can see in particular this:

MediaCodec              D  (0xb400007977f10fb0) configure format: AMessage(what = 0x00000000) = {
							float operating-rate = 48000.000000
							string log-session-id = "6T6xOhZNtcDfmPN0"
							int32_t sample-rate = 48000
							string mime = "audio/opus"
							int32_t channel-count = 2
							int32_t priority = 0
							int32_t max-output-channel-count = 99
                               }

where id is represented by parameter log-session-id .... I suspect maybe audioInputFormat doesn't check for log-session-id but for ID represented differently .... is that right?

If yes , is there a way to wrap someway that audioInputFormat to force read log-session-id as ID so it passes as not null and plays the stream? Maybe is there a way to communicate to DefaultRenderersFactory I am using the structure of that AMessage to identify as I implemented in this following code?

MediaItem mediaItem = new MediaItem.Builder().setUri(Uri.parse(url_media.toString()))
                .setMediaId("log-session-id")
		.setMimeType(MimeTypes.APPLICATION_RTSP)
		.build();   // used also MimeTypes.VIDEO_H264

renderersFactory = new DefaultRenderersFactory(this.getApplicationContext())
		.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON);

//.forceEnableMediaCodecAsynchronousQueueing();

ExoPlayer exoPlayer = new ExoPlayer.Builder(this.getApplicationContext())
		.setRenderersFactory(renderersFactory)
		.build();

exoPlayerView = this.findViewById(R.id.exoplayerui);
exoPlayerView.setPlayer(exoPlayer);
exoPlayer.addAnalyticsListener(new EventLogger());
exoPlayer.setMediaItem(mediaItem);
exoPlayer.prepare();
exoPlayer.setPlayWhenReady(true);

Or even better pass the name of ID label from my code so it would accept as parameter and read that parameter as ID because could depends from the source?... Because I tried to tell MediaItem .setMediaId("log-session-id") which as the documentation says it is used to set the optional media ID which identifies the media item but it didn't worked...

Thanks in advance!!
Cheers!!!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.