Commit graph

60 commits

Author SHA1 Message Date
Oliver Woodman
6bf817f107 Workaround EOS propagation for all devices with RK decoder.
As per the end of the related issue, it's likely that all devices
running the affected API levels + decoder are affected by the same
issue.

Issue #464
2015-10-12 12:12:43 +01:00
Oliver Woodman
e96e618046 Clean up expansion of sample buffers.
- The old approach was technically incorrect, because the checks
were "capacity < sampleSize" and hence neglected the fact that
the buffer position may be greater than 0 (e.g. if the caller
wants to prefix the sample with some additional data).

- Also proactively throw an exception if the buffer is too small,
rather than wait for the failure when we actually do the write.
2015-09-28 20:23:45 +01:00
Oliver Woodman
15c2f9c328 Explicitly set max input size for H264 decoders.
This works around an issue where some devices, such as the Acer Iconia,
don't allocate large enough input buffers for H264.

Issue: #616
Issue: #714
2015-09-28 12:38:35 +01:00
Oliver Woodman
cf27b83e8a Implement handlesTrack using MediaCodecUtil. 2015-09-18 18:22:40 +01:00
Oliver Woodman
820433de06 Call stop() to fully play out remaining audio!
Issue: #707
2015-09-10 18:19:09 +01:00
Oliver Woodman
143a4deee8 If no buffers were queued, handle EoS directly.
Issue: #707
2015-09-10 18:12:32 +01:00
Oliver Woodman
8e9aadc5e5 Workaround for vorbis EOS flush bug (23361053).
I'm assuming this will be fixed in API level 24.
2015-09-01 13:56:10 +01:00
Oliver Woodman
7d306ae593 Add language to MediaFormat + parse it from mdhd box.
+ Move conversion from framework -> exo format to FrameworkSampleSource.
+ Improve MediaFormat conversion test.
2015-08-11 18:10:46 +01:00
Oliver Woodman
b2206866f0 Use audio passthrough if possible, falling back to on-device codecs.
Remove MPEG TS stream filtering based on AudioCapabilities.

Pass AudioCapabilities to MediaCodecAudioTrackRenderer so it can choose between
passthrough/raw and decoding for AC-3 tracks.
2015-08-11 18:08:23 +01:00
Oliver Woodman
6085d185fa Internal plumbing for multi-track support.
- Generalize rendererEnabledFlags to be selected track indices through
  ExoPlayerImpl/ExoPlayerImplInternal.
- Selecting an out-of-bound track index (e.g. -1) is equivalent to
  disabling a renderer prior to the generalization.
- A prepared TrackRenderer that exposes 0 tracks is equivalent to a
  TrackRenderer in the STATE_IGNORE state prior to the generalization.

Issue #514.
2015-08-11 18:06:21 +01:00
Oliver Woodman
13f4a3e3bd Common base class for SampleSource based TrackRenderers.
This will allow multi-track support when consuming from a SampleSource to
be added in a single class, rather than in 6. Prep for Issue #514.
2015-08-11 18:04:00 +01:00
Oliver Woodman
ab3f623767 Workaround broken devices.
Issue #464
Issue #665
2015-08-07 17:28:03 +01:00
Oliver Woodman
a2f10399e7 Improve error propagation 2015-07-21 10:07:49 +01:00
Oliver Woodman
ebe9ae6b13 In continueBuffering, return whether a particular track has samples.
Issue: #595
2015-07-16 19:30:14 +01:00
Oliver Woodman
4282d7c22b Update MediaCodecTrackRenderer.
1. Workaround for decoders that fail to handle the END_OF_STREAM flag.
2. Revert processing of final output buffer if it's non-empty. This
   introduced another bug (#596)

Reverts: b88012f51f
Issue: #417
Issue: #596
2015-07-15 11:11:41 +01:00
Oliver Woodman
b88012f51f Process final output buffer if it's non-empty.
Issue: #417
2015-06-26 14:28:50 +01:00
Oliver Woodman
8e58a3f5f5 Steps toward full multi-track support.
1. Remove requirement for TrackRenderer implementations to report
   current position, unless they are time sources.
2. Expose whether renderers have media to play. The immediate benefit
   of this is to solve the referenced GitHub issue, and also to only
   display the appropriate Audio/Video/Text buttons in the demo app
   for the media being played. This is also a natural step toward
   multi-track support.

Github issue: #541
2015-06-18 14:27:24 +01:00
Oliver Woodman
a70c1f1a4b Remove requirement to specify downstream renderer count.
This makes it so that it's no longer necessary to specify the number
of downstream renderers to HlsSampleSource, FrameworkSampleSource and
ExtractorSampleSource, by forcing the downstream renderers to register
with the SampleSource instances in their constructors. This eliminates
a common source of subtle client bugs where the passed value is incorrect.
2015-06-12 17:52:56 +01:00
Oliver Woodman
926bc805f5 Add some useful Systrace 2015-06-05 18:28:42 +01:00
Oliver Woodman
67d0154960 Use Java7 <> syntax 2015-05-22 21:40:22 +01:00
Oliver Woodman
64cc380fe1 Avoid loading first chunk when preparing HLS for non-zero position.
This also fixes a technical mistake where HlsChunkSource is fed
seekPositionUs=-1 when obtaining the first chunk. This is wrong,
but the usage of this variable within HlsChunkSource enforces that
the seek must stay within bounds, so we get away with it.

Issue: #385
2015-05-11 21:10:20 +01:00
Oliver Woodman
3360f5eda5 Enable passthrough based on the input MIME type. 2015-05-08 17:04:21 +01:00
Oliver Woodman
f637fde962 Allow overriding of codec buffer dequeue block time. 2015-04-22 16:17:36 +01:00
Oliver Woodman
c3bf60b1a9 Add JavaDoc to remove lint warning about unused variable. 2015-04-14 16:45:46 +01:00
Oliver Woodman
d9b3582baa Use OMX.google.raw.decoder for passthrough playback.
The OMX component needs to be configured with a format that has a
MIME type of audio/raw. Remove Ac3PassthroughAudioTrackRenderer,
which is no longer used.
2015-04-14 16:42:24 +01:00
Oliver Woodman
6bf52dd69c Report decoder initialization information out of track renderer. 2015-04-10 23:06:57 +01:00
Oliver Woodman
a17123c49b Clean up codec reinitialization. 2015-04-10 23:03:50 +01:00
Oliver Woodman
d745384d99 Change decodeOnly to be a sample flag. 2015-04-10 22:55:12 +01:00
ojw28
9183525b5e Merge pull request #221 from martinbonnin/better_input_format_change_for_non_adaptive_codecs
better handling of input format change for non-adaptive codecs
2015-04-01 13:56:15 +01:00
Oliver Woodman
5d0457152d Remove need for InlinedApi with a few more C constants. 2015-03-11 15:48:12 +00:00
Oliver Woodman
8c1088559e Generalize getPsshInfo to properly accomodate WebM.
- Rather than returning a map, return a DrmInitData object,
  with mapped and non-mapped implementations.
- Include a suitable mimeType to pass to the MediaDrm. Previously
  we were incorrectly passing the mimeType of the samples,
  where-as MediaDrm expects the container mimeType. Note that
  it doesn't matter whether the mimeType starts with "video" or
  "audio", hence using video mimeTypes everywhere.
2015-03-10 19:42:48 +00:00
Oliver Woodman
a1d4a5e154 Continue waiting for keys until the codec is flushed.
It was possible for a codec input buffer to be filled with two frames' worth of
data, if seekTo was called after populating a buffer, if waitingForKeys was true
and seeking did not trigger a flush. This caused the CryptoInfo to be configured
as if the input buffer contained a large amount of reconfiguration data as
cleartext.

Move resetting waitingForKeys to flushCodec, so that we don't try to read the
next sample from the source until the first one has been consumed or discarded.
2015-03-03 18:16:22 +00:00
Oliver Woodman
bc99435b48 Add C.SAMPLE_FLAG_SYNC and removed InlinedApi suppression in a few places. 2015-02-13 20:20:45 +00:00
Oliver Woodman
61a86295fd Fix for video-only playbacks transitioning straight to STATE_ENDED.
The complexity around not enabling the video renderer before it
has a valid surface is because MediaCodecTrackRenderer supports
a "discard" mode where it pulls through and discards samples
without a decoder. This mode means that if the demo app were to
enable the renderer before supplying the surface, the renderer
could discard the first few frames prior to getting the surface,
meaning video rendering wouldn't happen until the following sync
frame.

To get a handle on complexity, I think we're better off just removing
support for this mode, which nicely decouples how the demo app
handles surfaces v.s. how it handles enabling/disabling renderers.
2015-02-12 17:02:34 +00:00
Martin Bonnin
e33e1d7922 cleaner test 2015-01-27 18:37:27 +01:00
Martin Bonnin
c228017fe4 rename hasQueuedOneInputBuffer to hasQueuedInputBuffer 2015-01-27 18:35:40 +01:00
Martin Bonnin
424b29f996 remove REINIT_STATE_DO_REINIT_NOW state, reinit directly when needed. 2015-01-27 10:44:02 +01:00
Martin Bonnin
79708f43f8 handle the case when flushCodec() is called while reiniting the decoders 2015-01-22 10:24:51 +01:00
Oliver Woodman
a879819dd3 Force callers into MediaCodecUtil to catch any exceptions that occur.
Issue: #217
Issue: #228
2015-01-12 17:40:55 +00:00
Martin Bonnin
e8a8c49a97 better handling of input format change for non-adaptive codecs
* this fixes a bug when switching from HE-AAC 22050Hz to AAC 44100Hz (the AudioTrack was not reset and we were trying to send a bad number of bytes, triggering a "AudioTrack.write() called with invalid size" error)
* this also improves quality switches, making it almost seamless
2014-12-23 13:47:50 +01:00
Oliver Woodman
2a832fd3c4 Minor stylistic tweaks. 2014-11-20 11:03:47 +00:00
ojw28
d506d7660d Merge pull request #147 from jonasl/dev-gc
MediaCodecTrackRenderer: Avoid excessive garbage generation
2014-11-19 16:08:38 +00:00
Oliver Woodman
127bcd18c3 Bring internal/external branches closer.
- Unredact internal error ids.
- Move images.
2014-11-19 15:58:26 +00:00
Jonas Larsson
255c3b27f6 MediaCodecTrackRenderer: Avoid excessive garbage generation
Looking up a long in a HashSet<Long> auto boxes the long and leaves
it for the GC. As decodeOnly is relatively infrequent it's much
better to do a simple linear search in a List<Long>. That way
we can avoid boxing every incoming time stamp value. In the general
case this will be linear searching in an empty list, a very fast
operation.

Signed-off-by: Jonas Larsson <jonas@hallerud.se>
2014-11-18 15:41:16 -08:00
Oliver Woodman
6a544da2f8 Use new MediaCodecList APIs on L. 2014-11-18 18:58:04 +00:00
Oliver Woodman
f1c646b793 Add diagnostic info to decoder exceptions + minor cleanup 2014-11-13 16:10:21 +00:00
Oliver Woodman
d2e73dd566 Add brackets to make expression clearer. 2014-11-06 19:26:41 +00:00
Oliver Woodman
5f6b197355 Allow direct and indirect buffer replacement.
Also tweak ManifestFetcher.
2014-10-27 10:58:43 +00:00
Oliver Woodman
027d9eefbd Smoother playback #1.
Propagate elapsedRealtimeUs to the video renderer. This allows
the renderer to calculate and adjust for the elapsed time since
the start of the current rendering loop. Typically this is <2ms,
but there situations where it can go higher (normally when the
video renderer ends up processing more than 1 output buffer in
a single loop).

Also made variable naming more consistent throughout the package.
2014-10-09 17:26:01 +01:00
Oliver Woodman
ec90eac301 Support anamorphic video content. 2014-09-11 16:34:35 +01:00