Commit graph

639 commits

Author SHA1 Message Date
Oliver Woodman
763d68f26c Bump to 1.3.2 2015-05-19 14:37:29 +01:00
Oliver Woodman
6ae97ced3a Support content:// URIs, and some cleanup/consistency tweaks.
- There's definitely potential for more code sharing in these
classes, but deferring for now.
- Also made no-scheme default to file://, and allowed smoothstreaming
URLs to be specified with or without the /Manifest suffix.
2015-05-19 14:14:53 +01:00
Oliver Woodman
a9c977a79e Fix Mp3Extractor synchronization when loading retries.
Before preparation, and when seeking, Mp3Extractor did not handle retrying:
- synchronizedHeader was set before the header was known to be valid, which
  means that after seeing one valid frame header and then failing to read, the
  synchronization would be treated as complete.
- The input buffer would keep data loaded during synchronization but on the next
  call to synchronize when retrying it was not returned to the mark position to
  re-parse the data.

This change fixes these issues.
2015-05-19 14:13:31 +01:00
Oliver Woodman
675c7738c1 Let DefaultUriDataSource load assets. 2015-05-19 14:12:59 +01:00
Oliver Woodman
f474afbf5e Fix handling of widths/heights when choosing formats.
- Make HlsPlaylistParser treat non-positive dimensions as unknown.
- Make HlsPlaylistParser parse floating point resolutions, because
  technically that's how they're spec'd.
- Make VideoFormatSelectorUtil treat non-position dimensions as unknown.

Issue: #461
2015-05-19 14:06:48 +01:00
Oliver Woodman
059b80c1ab Improve DataSource implementations:
1. Make DefaultUriDataSource robust against exceptions through from close().
2. Make AssetDataSource handle file:///android_asset/ URIs.
2015-05-19 14:05:50 +01:00
Oliver Woodman
672906060c Fix missing ID3 events
When I moved the id3Reader instantiation out of the while
loop (below where it is now) it was no longer guarded by
the streamTypes.get(streamType) deduping check. This brings
back an equivalent check.
2015-05-19 14:05:08 +01:00
Oliver Woodman
cd6c5c3984 Fix CBR seeking when XING header is present.
When a XING header is present but not usable (due to missing fields), CBR
seeking can be used instead. It relies on the bitrate. The bitrate from the
unusable XING header is not correct, which leads to incorrect seeking.

Also fix VBRI seeking by setting the correct offset on the frame to parse. Few
people seem to use that format, but I have found two very short truncated
samples which were falling back to the CBR case before but are using VBRI with
this change.
2015-05-19 14:03:39 +01:00
Oliver Woodman
d03fb10516 Remove readBitsLong, use readBits instead 2015-05-19 14:02:40 +01:00
Oliver Woodman
dd7a796883 Make constant public 2015-05-19 14:01:59 +01:00
Oliver Woodman
0dfc1d3bb7 Don't sample the timestamp/latency for AC-3 passthrough playback. 2015-05-19 14:00:49 +01:00
ood_tsen
b340d47165 support content uri (e.q. content://xxx) 2015-05-18 20:24:59 +08:00
Patrik Åkerfeldt
1469f11aa3 Support setting properties on MediaDrm 2015-05-13 10:41:22 +02:00
Oliver Woodman
5ca5df0bb2 Bump to 1.3.1 2015-05-12 18:42:46 +01:00
Oliver Woodman
06cbb4e746 Fix doc image refs 2015-05-12 16:57:39 +01:00
Oliver Woodman
166c2f7cc0 Fix two issues related to seeking with AC-3 output.
When a passthrough AudioTrack is replaced (due to seeking) the new one behaves
as if it is still emptying data from the old one, with its playback position
advancing until it runs out of data.

Data written while the 'old' AudioTrack was emptying would be discarded, so
avoid writing to the new AudioTrack while the old one is still emptying.

Also avoid using AudioTrack.getTimestamp with passthrough tracks, as this causes
the playback position to jump to a position that breaks audio/video
synchronization.
2015-05-11 21:16:02 +01:00
Oliver Woodman
79c7798d84 Reorganize BandwidthMeter interface 2015-05-11 21:11:53 +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
116a18848f Alter default exo buffertime value to 2500ms. 2015-05-11 21:05:37 +01:00
Oliver Woodman
b0abda43ec Ensure we configure a new extractor when we need one.
Issue: #400
2015-05-11 21:03:30 +01:00
Oliver Woodman
770ad7f06f Fix edge case in HlsSampleSource.
1. prepare() needs to load a TsChunk to actually prepare the source.
2. Source is prepared, but no tracks are enabled (this is why it's
   an edge case - no-one is likely to be doing this!).
3. The TsChunk load completes.

We should not load additional chunks in this case.
2015-05-11 21:02:38 +01:00
Oliver Woodman
dd5eabdf4a Signal EoS when seeking ExtractorSampleSource to the end of a track. 2015-05-11 21:01:35 +01:00
Oliver Woodman
861d6749ef Remove ability to extend the default FormatEvaluator implementations. 2015-05-08 17:09:39 +01:00
Oliver Woodman
9f77c4009e Clip seek position to the inputLength - 1. 2015-05-08 17:08:59 +01:00
Oliver Woodman
d9071710cf Read AC-3 tracks in MPEG TSs only if AC-3 playback is supported.
Partly fixes #434 as the AC-3 stream will now be ignored if the
audio capabilities don't allow it to be played back.
2015-05-08 17:08:13 +01:00
Oliver Woodman
d8af120b98 Fix treating all DVB data as AC-3.
Issue #434
2015-05-08 17:06:59 +01:00
Oliver Woodman
7437ee39d8 Remove deprecated method. 2015-05-08 17:06:27 +01:00
Oliver Woodman
54b71a5743 Allow cross-protocol redirects.
Issue: #423
2015-05-08 17:05:54 +01:00
Oliver Woodman
4527539efe Handle cenc:pssh elements in DASH manifests.
Issue: #407
2015-05-08 17:05:04 +01:00
Oliver Woodman
3360f5eda5 Enable passthrough based on the input MIME type. 2015-05-08 17:04:21 +01:00
Oliver Woodman
a1083d360a Prevent wrapping detection on new passthrough AudioTracks. 2015-05-08 17:03:05 +01:00
Oliver Woodman
de5bce3400 Apply passthrough workarounds only on platform API versions 21/22. 2015-05-08 17:02:23 +01:00
Oliver Woodman
9921dfd1ce Deprecate FrameworkSampleSource as a deterrent. 2015-05-05 20:33:25 +01:00
Oliver Woodman
6909c948b9 Remove SuppressLint in AudioTrack. 2015-05-05 20:32:06 +01:00
Oliver Woodman
9dcb17f21a Clean up DataSourceInputStream 2015-05-05 20:30:52 +01:00
Oliver Woodman
a63883a8c8 Fix format equality checking.
For Live SmoothStreaming, referential equality checking
isn't enough (it breaks once the manifest is updated).
Updated other instances too just for consistency.
2015-05-05 20:30:32 +01:00
Tanuj Mittal
2a06c2641c Fix DataSourceInputStream.read() for EOF cases 2015-05-05 16:30:09 +05:30
Oliver Woodman
79cdd03682 Filter unsupported video formats for HLS. 2015-05-01 20:34:57 +01:00
Oliver Woodman
b405d3d9b7 Have Representation, TrackElement and Variant consistently expose Format.
And delete things that we're parsing but don't use from TrackElement.
2015-05-01 20:33:52 +01:00
Oliver Woodman
8673cafce8 Move Allocator to HlsSampleSource (from HlsChunkSource).
- This makes HLS consistent with Chunk/ExtractorSampleSource.
- It needs to be consistent for WebVTT in HLS.
- Also trim the allocator when done.
2015-05-01 20:32:42 +01:00
Oliver Woodman
0c5a1a6c35 Distinguish exceptions caught at top level. 2015-05-01 20:31:49 +01:00
Oliver Woodman
efb9ff1fe7 Play standalone MPEG-TS files.
- Have TsExtractor report a SeekMap to the output.
- Implement TsExtractor.reset to reset extractor state.
- Add 1x sample.
2015-05-01 20:31:21 +01:00
Oliver Woodman
cfab852096 Remove pointless references to ElementaryStreamReaders. 2015-05-01 20:30:00 +01:00
Oliver Woodman
d82343d06c Remove MediaFormat.bitrate. 2015-05-01 20:29:32 +01:00
Oliver Woodman
54f97c952e Reintroduce Allocation abstraction.
Play movies has an Allocator that attempts to allocate a single
huge byte[] up front to minimize the risk of GC pauses. This abstraction
will be required to keep that when updating them to the new Exo.
2015-05-01 20:28:49 +01:00
Oliver Woodman
9b112cf94d Video format selection.
Making Representation and TrackElement extend Format will simplify
this further (TBC whether this is a good idea!).

Issue: #393
2015-05-01 20:27:11 +01:00
Oliver Woodman
fafcd79e1b Move AC-3 bitrate calculation into Ac3Util.
This is in preparation for removing bitrate from MediaFormat.
2015-05-01 20:25:19 +01:00
Oliver Woodman
6bf62770bd Make sure that the process dies if a loading task throws Error. 2015-05-01 20:24:50 +01:00
Oliver Woodman
1d528b80ea Move getUserAgent from DemoUtil to library's Util. 2015-05-01 20:24:27 +01:00
Oliver Woodman
6cb46e4549 webm_extractor: Add VP8 to the list of codecs.
VP8 can be decoded by MediaCodec (since very early versions of android). Now that we want WebmExtractor to be general purpose, adding VP8 makes sense as it is a common use case.
2015-05-01 20:23:33 +01:00
Oliver Woodman
5ea7424ee3 Tidy up AssetDataSource. 2015-05-01 20:23:02 +01:00
Oliver Woodman
ce3d5c9a59 Throw when getMinBufferSize returns an error value. 2015-05-01 20:22:03 +01:00
Oliver Woodman
e6c7defc79 Make ParsableBitArray.data public, like ParsableByteArray. 2015-05-01 20:21:36 +01:00
Oliver Woodman
7ad55dbf2c webm_extractor: Add support for parsing BlockGroup element
This CL adds support for parsing BlockGroup elements for all
codecs (not just opus). It also adds a test to verify the new
behavior.
2015-05-01 20:20:47 +01:00
Oliver Woodman
aed45bb2ca Add support for reading AC-3 audio in HLS. 2015-05-01 20:18:08 +01:00
Oliver Woodman
48fc9635a9 webm_extractor: Add support for Cues present at the end of file
This CL adds support for WebM files which have Cues present at the end of the file (i.e.) after Clusters. The file referenced in the bug can now be played back using the demo app. It adds a new flag to WebmExtractor which should be set to true only when being used through ExtractorSampleSource. All others (e.g. DASH) should not set it.

Reference file: http://demos.webmproject.org/exoplayer/glass_vp9_vorbis_cues_at_end.webm
2015-05-01 20:13:19 +01:00
Oliver Woodman
6cccfc1caa Make Atom.getAtomTypeString public.
I've found myself doing this a couple of times during local
debugging. It's harmless to have it public, and seems pretty
useful for debugging inside of the mp4 package.
2015-05-01 20:12:28 +01:00
Oliver Woodman
b787852e71 Correctly stop previous renderers if prepare is called again. 2015-05-01 20:11:57 +01:00
Oliver Woodman
88daaa882c Fix NPE if source is released having never been prepared. 2015-05-01 20:11:27 +01:00
Oliver Woodman
837090e8f9 Move AC-3 header parsing into a new Ac3Util class.
This is in preparation for adding support for AC-3 in HLS.

Also parse E-AC-3 boxes.
2015-05-01 20:10:47 +01:00
ojw28
26c5461b10 Merge pull request #408 from dnutcracker/dev
fix for issue #403
2015-04-24 11:51:11 +01:00
Nati Dykstein
a43dd6ba68 Update AssetDataSource.java 2015-04-22 22:25:44 +03:00
Oliver Woodman
f273c73123 Support NALUnitLengthFieldLength != 4.
Seems a little hacky to define this in Track, but there doesn't seem to
be a particularly nice alternative.

Issue: #406
2015-04-22 16:24:12 +01:00
Oliver Woodman
afb1a93059 Refine ExtractorSampleSource retry.
I was hoping not to avoid this, but in the case of a parsing
failure during preparation we keep retrying forever!
2015-04-22 16:23:33 +01:00
Oliver Woodman
1a01dcc55a Separate UriDataSource from HttpDataSource.
Using a file:// URL for loading an HLS stream (for testing) would fail due to
casting the connection to an HttpURLConnection in DefaultHttpDataSource.

This change makes UriDataSource an interface for objects that are DataSources
with URIs. That allows for reading manifests for HLS using just a UriDataSource
rather than an HttpDataSource (URLs in the playlist are relative to the data
source's URL so the getUri method is needed).
2015-04-22 16:22:48 +01:00
Oliver Woodman
a1336978ad Fix DataSpec toString formatting. 2015-04-22 16:19:48 +01:00
Oliver Woodman
c807c69a93 webm_extractor: Support for multiple tracks
Github Issue: #363
2015-04-22 16:18:23 +01:00
Oliver Woodman
f637fde962 Allow overriding of codec buffer dequeue block time. 2015-04-22 16:17:36 +01:00
Oliver Woodman
1a9bf018a4 Add frame rate to Format for use in format selection (when known). 2015-04-22 16:16:42 +01:00
Oliver Woodman
a7e2b719c5 Call init() on the extractor only once for each chunk.
On retrying loading a chunk, the state of the extractor was reset due to a call
to seek(). Prevent this call by only calling init() if no bytes were loaded.

Also make the DefaultExtractorInput use the loading position not the original
stream position so that its getPosition() method returns offsets relative to
the start of the stream, which fixes a bug where the chunk index offsets would
be relative to the wrong position if there was a retry while loading the chunk.
2015-04-22 16:14:46 +01:00
Oliver Woodman
21e69f3154 Add more loading info (including chunk loading times) to
BaseChunkSampleSourceEventListener.onLoadCompleted.
2015-04-22 16:13:19 +01:00
Oliver Woodman
3a1325b0af Make TsExtractor consistent with AdtsExtractor. 2015-04-22 16:11:23 +01:00
Nati Dykstein
647d9bedb8 fix for issue #403 2015-04-22 14:51:05 +03:00
Oliver Woodman
55e08ff712 Avoid time discontinuity when retrying a live stream.
Issue: #227
Issue: #389
2015-04-17 20:12:11 +01:00
Oliver Woodman
faf0e2c147 Improve retry logic.
1. Reset retry count to 0 if a Loadable makes progress.
2. Handle resume correctly in the case of live streams.

Issue: #227
Issue: #389
2015-04-17 20:10:31 +01:00
Oliver Woodman
4c94a846d5 webm_extractor: Fix issue in vorbis extraction.
Vorbis decoder in android MediaCodec [1] expects the last 4 bytes of the sample to be the number of samples in the current page. This definition holds good only for Ogg and is irrelevant for WebM. So we always set this to -1 (the decoder will ignore this value if we set it to -1). The android platform media extractor [2] does the same.
2015-04-17 20:09:45 +01:00
Oliver Woodman
b1aac839e6 Don't feed AC-3 input when the audio track is paused.
This works around an issue the audio track continues to play audio data written
after calling AudioTrack.pause(), which breaks rebuffering behavior (as video
can never catch up if audio continues to be consumed, in some circumstances).

Also don't increment the timestamp wrap count if the track is paused, to work
around an issue where the playback head position jumps back to zero after the
AudioTrack position jumps back to zero.
2015-04-17 20:08:54 +01:00
Oliver Woodman
c4eee71fa2 Support AAC without platform MediaExtractor.
Issue: #231
Issue: #227
2015-04-17 20:07:04 +01:00
Oliver Woodman
fb97fca04e Handle dynamic appearance/disappearance of ID3 track in HLS. 2015-04-17 20:04:52 +01:00
Oliver Woodman
5f74226d67 Make the audio track session workaround flag non-final. 2015-04-17 20:04:18 +01:00
Oliver Woodman
508e13e0bd Clean up + optimize ParsableByteArray. 2015-04-17 20:03:24 +01:00
Oliver Woodman
9092fad8e8 Fix subtitles. 2015-04-17 20:02:20 +01:00
Oliver Woodman
0523717841 Fix crash. 2015-04-17 20:01:59 +01:00
Oliver Woodman
e84c852169 Select E-AC-3 in preference to AC-3, and remove other tracks. 2015-04-17 20:01:06 +01:00
Oliver Woodman
3f1638de95 Use ENCODING_PCM_16BIT for keepSessionIdAudioTrack.
ENCODING_PCM_8BIT support is not required.
2015-04-17 19:59:58 +01:00
Oliver Woodman
e4e6a1caf0 Switch from AudioFormat.ENCODING_DEFAULT to .ENCODING_PCM_16BIT.
AudioTrack.getMinBufferSize does not handle ENCODING_DEFAULT so
switch back to ENCODING_PCM_16BIT.
2015-04-17 19:59:03 +01:00
Oliver Woodman
c3bf60b1a9 Add JavaDoc to remove lint warning about unused variable. 2015-04-14 16:45:46 +01:00
Oliver Woodman
7cf6aa86d2 Properly document in code how to pass CustomData to PlayReady DRM.
Issue: #339
2015-04-14 16:44:01 +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
ed1dbddc75 Trim memory when disabling ExtractorSampleSource.
This prevents memory leakage even in the case where the app
is still holding a reference (direct or indirect) to the
Allocator.
2015-04-13 19:36:16 +01:00
Oliver Woodman
0d69a2eae8 Implement event reporting from HlsSampleSource.
Issue: #275
2015-04-13 19:03:04 +01:00
Oliver Woodman
e21f7801b5 Major surgery to move all playback modes to the new Extractor model. 2015-04-13 18:57:31 +01:00
Sergio Moreno Mozota
e5acc5a2c8 resync with Extractor changes 2015-04-13 16:58:19 +02:00
Sergio Moreno Mozota
da7ae2a925 Merge remote-tracking branch 'upstream/dev' into dev 2015-04-13 15:56:43 +02:00
Oliver Woodman
265adf9a8f Move chunk trigger constants into Chunk. 2015-04-11 02:09:40 +01:00
Oliver Woodman
ad56490bde Add ability to discard from write-side of DefaultTrackOutput. 2015-04-11 02:03:43 +01:00
Oliver Woodman
4c8f9a8c6f Remove source package, and restore original FrameworkSampleSource. 2015-04-11 02:00:47 +01:00
Oliver Woodman
587edf8e2b Add new style mp4/fmp4 extractors. 2015-04-11 01:58:34 +01:00
Oliver Woodman
7d8141e419 Add new style mp3 extractor. 2015-04-11 01:42:03 +01:00
Oliver Woodman
4a1fed9e86 Add new style WebM extractor. 2015-04-11 01:30:11 +01:00
Oliver Woodman
6c5af23230 Minor tweaks to HlsSampleSource. 2015-04-11 01:12:40 +01:00
Oliver Woodman
da656e6f26 More steps towards unified extractors. 2015-04-11 01:07:41 +01:00
Oliver Woodman
53a47524a1 Support non-square pixels in HLS.
Github issue: #375
2015-04-11 00:59:00 +01:00
Oliver Woodman
37d12ff14a Steps toward generalizing the Extractor interface for all extractors. 2015-04-11 00:55:38 +01:00
Oliver Woodman
3a551c73ba Move hls.parser to a new extractor package.
This package will house all extractors, which will be unified
to implement a single Extractor interface.
2015-04-11 00:27:24 +01:00
Oliver Woodman
fc176b9cbe Fix TsExtractor bug.
The limit on the ts packet buffer can be reduced during processing
if it's discovered to have padding. Hence we need to reset it back
to the ts packet size before processing each packet.
2015-04-10 23:41:45 +01:00
Oliver Woodman
61443b2f12 Relocate content of Mp4Util to more sensible locations.
- Atom related stuff in Mp4Util is moved to Atom.
- Remainder of Mp4Util is renamed to H264Util.
2015-04-10 23:31:03 +01:00
Oliver Woodman
fea2140d57 Add ability to query size/rate support in MediaCodecUtil. 2015-04-10 23:15:52 +01:00
Oliver Woodman
38efb1fc3f Clean up Aes128DataSource. 2015-04-10 23:12:47 +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
380c427fb3 Make MediaCodecVideoTrackRenderer easier to extend. 2015-04-10 23:01:09 +01:00
Oliver Woodman
a085d2f29b Add END_OF_INPUT constant + start using it. 2015-04-10 23:00:23 +01:00
Oliver Woodman
d745384d99 Change decodeOnly to be a sample flag. 2015-04-10 22:55:12 +01:00
Oliver Woodman
70b0e55a8b Remove deprecated bandwidth parameter. 2015-04-10 22:39:15 +01:00
Oliver Woodman
c901025643 Don't attempt license request when keys expire.
- Keys should not expire during normal playbacks of correctly configured content.
- Attempting to refresh on expiration causes a race condition, that may result
  in either failure or brief re-buffer, for the 30s license test video.
- This change provides deterministic behavior, which is to always fail.
2015-04-10 22:38:06 +01:00
Oliver Woodman
d108c13535 Remove deprecated method. 2015-04-10 22:36:07 +01:00
Oliver Woodman
4dc8e8f951 Add audio and m3u8 mime types. 2015-04-10 22:35:03 +01:00
Oliver Woodman
ecaf329b0d Improve ParsableByteArray performance + enhance API. 2015-04-10 22:34:06 +01:00
Oliver Woodman
ed658b8e8d Attempt to guard against ExoCache corruption. 2015-04-10 22:33:10 +01:00
Oliver Woodman
cfcbca6c95 Make FileDataSource throw EOFException. 2015-04-10 22:29:51 +01:00
Oliver Woodman
362dc5f382 Don't fail if server doesn't support partial requests.
Some servers, probably edge cache machines that exclusively serve
chunked media, don't support partial requests. Which is kind of
vaguely reasonable for that particular case. This change modifies
DefaultHttpDataSource to correctly handle this case, by manually
skipping data up to the requested position (and making sure not to
read more data than the requested length).
2015-04-10 22:28:20 +01:00
Oliver Woodman
1a198b8a30 Minor cleanup (remove deprecated method, fix javadoc) 2015-04-10 22:24:39 +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
acd1b9acff Enable ContentProtect elements at the Representation level 2015-03-31 11:28:51 +01:00
Oliver Woodman
5a5935cb72 Fix HLS playlist parsing of boolean attributes.
The regex included quotation marks like X="YES", but the manifests
don't actually contain them, for examples X=YES.
2015-03-30 15:56:39 +01:00
Oliver Woodman
b73b9a0509 Add workaround for #252 (but don't enable it by default). 2015-03-25 12:08:45 +00:00
Oliver Woodman
e54d07c1b0 Fix issue with new extractor input 2015-03-17 12:36:46 +00:00
Andrew Lewis
5e4a35fa7e Add Mp4SampleExtractor, for reading unfragmented MP4 files. 2015-03-13 18:10:37 +00:00
Andrew Lewis
6d8c4dd416 Add workaround for slow okhttp InputStream.close() on API levels 19/20. 2015-03-13 18:06:00 +00:00
Oliver Woodman
a22ccf9254 Another baby step to unified extractors.
- Have extractors read from an ExtractorInput. Benefits of this are
  (a) The ability to do a "full" read or skip of a specified number
  of bytes, (b) The ability to do multiple reads in your extractor's
  read method. The ExtractorInput will throw an InterruptedException
  if the read has been canceled.

- Provides the extractor with the ability to query the absolute
  position of the data being read in the stream. This is needed for
  things like parsing a segment index in fragmented mp4, where the
  position of the end of the box in the stream is required because
  the index offsets are all specified relative to that position.
2015-03-13 11:47:51 +00:00
Oliver Woodman
1111dd73a0 Further simplify HlsExtractor interface.
- Move to builder naming.
- Propagate formats to the TrackOutput instances, rather than having
  them be read through the Extractor. There was actually some weird
  indexing going on here before (which happened to work, but wasn't
  well defined).
2015-03-13 11:44:27 +00:00
Oliver Woodman
12807a7d4b Simplify encryption handling in HLS. 2015-03-12 19:44:06 +00:00
Damien Merenne
94dd9c41f4 Fix AES decryption of HLS streams.
As per http://tools.ietf.org/html/draft-pantos-http-live-streaming-04#section-5.2,
the initializaton vector (IV) of the AES decryption algorithm should be set to:
- the IV attribute value if present,
- the sequence number otherwise.

Currently, the IV is set once and use over all next media sequences
where the IV attribute is not set. The fix is to use the provided IV if
given or use the current media sequence number.
2015-03-12 13:34:58 +01:00
Oliver Woodman
5ca2e0fd95 First step toward extractor unification.
- It's probably easiest to think of this as a standalone HLS change, which is splitting out the "loading" and "consuming" sides of HlsExtractor and a good structural change in its own right. To do this, HlsExtractorWrapper becomes a final class implementing the consuming side. HlsExtractor becomes an interface defining the loading side.

- The bigger picture is that, hopefully, HlsExtractor will become a lightweight extractor interface that can be used throughout the library. Because it doesn't need to implement the consuming side, we'll save on having to re-implement the consuming side for every extractor (we'll probably need one consuming side implementation for HLS/DASH/SmoothStreaming, and a second one for everything else, both of which will use SampleQueue). It's expected that the HlsExtractor interface will need to change to accommodate all use cases.

- The next step in unification will be to try and have FragmentedMp4Extractor implement HlsExtractor (which will need renaming). Once this is done, I'll try and move the chunk package over to use the HlsExtractor interface.
2015-03-11 19:21:33 +00:00
Oliver Woodman
becc6fca4c Enhance SampleQueue/RollingSampleBuffer to support other use cases.
- This is a step toward hopefully converging HLS and CHUNK packages.
- Add support for encrypted samples.
- Add support for appending from a DataSource.
2015-03-11 15:49:53 +00:00
Oliver Woodman
5d0457152d Remove need for InlinedApi with a few more C constants. 2015-03-11 15:48:12 +00:00
Oliver Woodman
56a509d8e4 Clean up handling of encrypted samples in fmp4/webm extractors.
- The fmp4 extractor was reading from sampleEncryptionData even
  for not-encrypted samples, which I'm pretty sure isn't right.
  Fixed this. For all encrypted content I've seen, this change
  will be a no-op because isEncrypted is always true if there's
  an encryptionBox present.
- Made webm extractor only set cryptoInfo if isEncrypted is true.
- Align variable naming in the two extractors, for clarity.
2015-03-10 21:44:20 +00:00
Oliver Woodman
5e11b9f008 Add DrmInitData (missed from a previous commit). 2015-03-10 19:48:41 +00:00
Oliver Woodman
eba16e55b0 Support delayed loading by Loader. 2015-03-10 19:43:25 +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
eec6458b43 Add handling of Extended Western European character set for CEA-608. 2015-03-10 19:37:47 +00:00
Oliver Woodman
4192ac56af WebM Extractor support for Encrypted content. 2015-03-10 19:36:37 +00:00
Oliver Woodman
1ebaaaebd5 Parse EXT-X-MEDIA tags with SUBTITLES type.
Not yet used by anything.

Issue: #151
2015-03-10 19:07:19 +00:00
Oliver Woodman
be103106cb HLS: Better stream selection at start of playback.
- Correctly handle bandwidth NO_ESTIMATE case.
- Don't consider switching without a previous chunk.
2015-03-10 19:06:07 +00:00
Oliver Woodman
489e99158f Remove getDurationUs from the SampleExtractor interface.
Set the duration on the MediaFormat instead.
2015-03-10 19:04:38 +00:00
Oliver Woodman
cdf19430ef Remove TrackInfo from the SampleExtractor interface. 2015-03-10 19:01:11 +00:00
Oliver Woodman
462fea3eaf Correctly resolve Uris according to RFC3986.
Issue: #327
2015-03-05 11:56:00 +00:00
Sergio Moreno Mozota
9208c655d1 fix false positives in sync word detection thanks to @jeoliva 2015-03-04 20:46:22 +01:00
Oliver Woodman
457557b56f Parse ISO8601 timestamps using UTC timezone. 2015-03-04 11:02:43 +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
baea1cd12d Add ftyp atom def 2015-03-03 17:17:02 +00:00
Oliver Woodman
b9addf28b2 Formatting tweaks for enhanced ID3 support + support in demo app. 2015-03-03 17:16:13 +00:00
Oliver Woodman
0c6566bce7 Add flags to DataSpec. Support GZIP option.
Also remove uriIsFullStream. It's not doing anything particularly
useful, so I think it makes sense to remove it from the public API;
it's unlikely anyone is using it.

Issue: #329
2015-03-03 17:14:48 +00:00
Oliver Woodman
3868b1d4cb Clean up media playlist blacklisting / fix nits.
It seems fairly safe to assume a playlist wont be blacklisted
within 1ms of the device booting :).
2015-03-03 17:11:21 +00:00
J. Oliva
b03c8a713b Mime type string always finish with a single 0 byte
Mime type string always finish with a single 0 byte
2015-02-28 00:47:42 +01:00
J. Oliva
88475e4fee Fixed issue in the calculation of size of objectData
- Fixed issue in the calculation of size of objectData
- Indentation fixes
2015-02-27 22:09:05 +01:00
Sergio Moreno Mozota
2ce938d650 Added MPEG audio support to TsExtractor v.2 2015-02-27 14:29:21 +01:00
J. Oliva
1739af685a Removed indexOfNot method
Removed the unused method indexOfNot
2015-02-27 11:02:37 +01:00
J. Oliva
f33cdd97e6 Fixed an issue when looking for termination string in UTF-16 and UTF-16BE
Modified parse method to take into account different lengths for the
termination character (1 for UTF-8 and ISO-8859-1; 2 for UTF-16 and
UTF-16BE).
2015-02-27 10:57:43 +01:00
J. Oliva
c135bb7a57 Fixes for correctly supporting UTF-16 and UTF-16BE charsets
For fields encoded using UTF-16 or UTF-16BE charsets when looking for
termination character we have to look for two zero consecutive bytes.

Otherwise, as many characters encoded with UTF-16 or UTF-16BE has one
of their 2 bytes set with the value zero, we will be truncating text
fields.
2015-02-26 21:54:29 +01:00
Sergio Moreno Mozota
1545a052f0 Added MPEG audio support to TsExtractor 2015-02-26 19:12:58 +01:00
J. Oliva
ebbd022a52 Added new ID3 frames
- Added support for ID3 frames of types GEOB and PRIV.

 - GEOB type is commonly used by dynamic ads provider to include in the
stream information about the ads to be played.
 - PRIV type is commonly used for time synchronization (example:
synchronizing playback of a live stream and its webvtt captions) and
also by analytics companies to include tracking information in the
stream.

- Added a sample stream from Apple that contains ID3 metadata.
2015-02-26 16:49:05 +01:00
ojw28
ea95db2375 Merge pull request #316 from jeoliva/blackplaylist_management
Better management of blacklisted playlists
2015-02-25 14:33:26 +00:00
Oliver Woodman
006986cc58 Make NetworkLoadable use an injected HttpDataSource.
Note: I'm fairly confident that NetworkLoadable.Parser implementations
can live without the inputEncoding being specified. But not completely
100%...

Issue: #311
Issue: #56
2015-02-25 13:39:15 +00:00
Oliver Woodman
2ce17b601f Correctly bound search into segment indices.
The return value here assumed that the time being searched for
was beyond the start time of the last segment. This fix also
handles the case where the time is prior to the start of the
first segment.
2015-02-25 13:34:31 +00:00
Oliver Woodman
d2da3bbf8a Simplify NetworkLoader/Parser/ManifestParser
The only downside of this change is that MediaPresentationDescriptionParser
is no longer stateless.
2015-02-25 12:09:06 +00:00
Oliver Woodman
0fdcb3347c continueBuffering should return true when ended.
This issue didn't have any material impact on playbacks, but
fixing it anyway to be technically correct.
2015-02-25 11:48:55 +00:00
Oliver Woodman
d6ebd49c63 Two small fixes for HLS.
1. Clear prefixFlags when a NAL unit is found.
2. continueBuffering should return true if loading is finished.
2015-02-25 11:37:39 +00:00
J. Oliva
2ac7046ffc Clear stale blacklisted playlist when getting next variant index
Calling clearStaleBlacklistedPlaylist within getNextVariantIndex method.
2015-02-23 22:42:53 +01:00
J. Oliva
4fe62b9b0a Clear stale blacklist in getChunkOperation
Clear stale blacklist in getChunkOperation before getting next variant.
This ensures:
1.- Player resilience to failures, always trying to look for a working
playlist that allows player to non stop playback.
2.- High quality blacklisted playlists can be reused in case they go up
after a failure. Player always trying to provide the best user
experience.
2015-02-23 20:40:37 +01:00
J. Oliva
f8a9da90e8 Renaming methods and code formating
- Method evaluatePlayListBlackListedTimestamps renamed to
clearStaleBlacklistedPlaylists
- Code formatted to be consistent with style elsewhere.
2015-02-23 20:06:49 +01:00
J. Oliva
20a40f5d11 Better management of blacklisted playlists
Added an expiration time field to playlists blacklisted to allow
Exoplayer to continue playback when playlists that failed were
recovered from a bad state.

In live environments, some times occur that primary encoder stop
working for a while. In that cases, HLS failover mechanism in the
player should detect the situation and “switch” to playlists served by
the backup encoder (in case a backup encoder exists). This was well
managed before these changes.

However, and to ensure a playback experience that can recover itself
from temporary issues, we cannot blacklist a playlist forever. When
streaming live events using HLS, it is quite typical that the player
needs to switch from primary to backup playlists, and from backup to
primary ones, from time to time to have playback working when temporary
issues in the network/encoder are happening. Most of the issues are
recoverable, so what I have implemented is a mechanism that makes
blacklisted playlist to be available again after a while (60 seconds).

Evaluation of this algorithm should happen just when something fails.
If player is working with a backup playlist, it shouldn’t switch to the
primary one at least something fail.
2015-02-23 15:14:09 +01:00
Oliver Woodman
6d14fc3330 Implement UTC time synchronization for DASH Live.
Support is provided for the following schemes:

urn:mpeg:dash:utc:direct:2012
urn:mpeg:dash:utc:http-iso:2014
urn:mpeg:dash:utc:http-xsdate:2012
urn:mpeg:dash:utc:http-xsdate:2014
2015-02-20 15:10:25 +00:00
Oliver Woodman
4076b08e4b Naming tweak 2015-02-20 15:07:22 +00:00
Oliver Woodman
b510088689 Fix EIA-608 issues.
- Data needs to be unescaped before it's passed to SeiReader.
- SeiReader should loop over potentially multiple child messages.
- I also changed the sample passed to the EIA-608 renderer so that
  it's the entire sei message payload. The first 8 bytes are
  unnecessary, but it seems nicer conceptually to do it this way.

Issue: #295
2015-02-19 11:22:42 +00:00
J. Oliva
e84bce6130 Fixed issue in CODEC regular expression
Previous regular expression for extracting codec information was wrong,
given a line that defines a variant it added information from “CODEC=“
text to the end of the line (including also information about
RESOLUTION or alternate rendition groups as part of the CODEC field).

This is not causing a functional problem (at least known by me)
although is making codecs field storing information that is not related
with the codec.
2015-02-19 01:17:35 +01:00
Oliver Woodman
abac6b7dd6 Fix off-by-one-bug preventing NAL unit detection at the limit. 2015-02-18 19:11:52 +00:00
Oliver Woodman
b03c5c5753 Ensure we always seek after selecting a track.
Some extractor implementations underneath MediaExtractor require a seekTo
call after tracks are selected to ensure samples are read from the correct
position. De-duplicating logic was preventing this from happening in some
cases, causing issues like:

https://github.com/google/ExoPlayer/issues/301

Note that seeking all tracks a side effect of track selection sucks if
you already have one or more tracks selected, because it introduces
discontinuities to the already selected tracks. However, in general, it
*is* necessary to specify the position for the track being selected,
because the underlying extractor doesn't have enough information to know
where to start reading from. It can't determine this based on the read
positions of the already selected tracks, because the samples in these
tracks might be very sparse with respect to time.

I think a more optimal fix would be to change the SampleExtractor
interface to receive the current position as an argument to selectTrack.
For our own extractors, we'd seek the newly selected track to that
position, whilst the already enabled tracks would be left in their
current positions (if possible). For FrameworkSampleExtractor we'd
still have no choice but to call seekTo on the extractor to seek all
of the tracks. This solution ends up being more complex though, because:

- The SampleExtractor then needs a way of telling DefaultSampleSource
  which tracks were actually seeked, so that the pendingDiscontinuities
  flags can be set correctly.
- It's a weird API that requires the "current playback position to seek
  only the track being enabled"

So it may not be worth it! I think this fix is definitely good for now,
in any case.

Issue: #301
2015-02-18 15:15:20 +00:00
Oliver Woodman
cc7a15b79b Fix bad assertion 2015-02-18 15:09:45 +00:00
Oliver Woodman
526c64294a Handle the edge case of zero-length chunks.
Issue: #289
2015-02-17 16:04:44 +00:00
Oliver Woodman
a1e196fe20 Add support for elementary AAC/ADTS streams.
- This change:

1. Extracts HlsExtractor interface from TsExtractor.
2. Adds AdtsExtractor for AAC/ADTS streams, which turned out to be
   really easy.

Selection of the ADTS extractor relies on seeing the .aac extension.
This is at least guaranteed not to break anything that works already
(since no-one is going to be using .aac as the extension for something
that's not elementary AAC/ADTS).

Issue: #209
2015-02-17 15:42:38 +00:00
Oliver Woodman
b46d1fc7cc Bump dev version to 1.3.x 2015-02-16 22:30:28 +00:00
Oliver Woodman
3472e86c36 Correctly reset ADTSreader state 2015-02-16 22:22:25 +00:00
Oliver Woodman
40411269da Use C.SAMPLE_FLAG_SYNC 2015-02-13 20:36:27 +00:00
Oliver Woodman
9d480ecd20 Fix broken javadoc link 2015-02-13 20:34:30 +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
5f64a1fde7 Restrict HLS buffering by total buffer size as well as duration.
This prevents excessive memory consumption when switching to
very high bitrate streams.

Issue: #278
2015-02-13 20:13:11 +00:00
Oliver Woodman
c3788c0931 Eliminate memory copy of H264 data through H264 reader.
I think this is the limit of how far we should be pushing complexity
v.s. efficiency. It's a little complicated to understand, but probably
worth it since the H264 bitstream is the majority of the data.

Issue: #278
2015-02-13 20:11:12 +00:00
Oliver Woodman
37e6946cd9 Finally - Remove Sample, fix GC churn + inefficient memory usage.
Use of Sample objects was inefficient for several reasons:

- Lots of objects (1 per sample, obviously).
- When switching up bitrates, there was a tendency for all Sample
  instances to need to expand, which effectively led to our whole
  media buffer being GC'd as each Sample discarded its byte[] to
  obtain a larger one.
- When a keyframe was encountered, the Sample would typically need
  to expand to accommodate it. Over time, this would lead to a
  gradual increase in the population of Samples that were sized to
  accommodate keyframes. These Sample instances were then typically
  underutilized whenever recycled to hold a non-keyframe, leading
  to inefficient memory usage.

This CL introduces RollingBuffer, which tightly packs pending sample
data into a byte[]s obtained from an underlying BufferPool. Which
fixes all of the above. There is still an issue where the total
memory allocation may grow when switching up bitrate, but we can
easily fix that from this point, if we choose to restrict the buffer
based on allocation size rather than time.

Issue: #278
2015-02-13 19:32:01 +00:00
Oliver Woodman
28166d8c0d Rename ParsableByteArray.length() to limit(). Add capacity(). 2015-02-13 19:31:01 +00:00
Oliver Woodman
321005e4b1 Use 'bitrate' not 'bit-rate' consistently. 2015-02-13 19:27:52 +00:00
Oliver Woodman
d1360ad7d2 Pragmatic fix for "stuck-in-ready-state" when seeking near the
end of some streams.
2015-02-13 19:26:49 +00:00
Oliver Woodman
066334dad7 Continue TsExtractor refactor.
- Remove TsExtractor's knowledge of Sample.
- Push handling of Sample objects into SampleQueue as much
  as possible. This is a precursor to replacing Sample objects
  with a different type of backing memory. Ideally, the
  individual readers shouldn't know how the sample data is
  stored. This is true after this CL, with the except of the
  TODO in H264Reader.
- Avoid double-scanning every H264 sample for NAL units, by
  moving the scan for SEI units from SeiReader into H264Reader.

Issue: #278
2015-02-12 17:24:23 +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
Oliver Woodman
784431f3e0 Move EIA reordering back to the renderer (sorry for churn).
Reordering in the extractor isn't going to work well with the
optimizations I'm making there. This change moves sorting back
to the renderer, although keeps all of the renderer
simplifications. It's basically just moving where the sort
happens from one place to another.
2015-02-12 12:48:27 +00:00
Oliver Woodman
f7fb4d4c35 Optimize NAL unit search.
I'm not really a fan of micro-optimizations, but given this method
scans through every H264 frame in the HLS case, it seems worthwhile.
The trick here is to examine the first 7 bits of the third byte
first. If they're not all 0s, then we know that we haven't found a
NAL unit, and also that we wont find one at the next two positions.
This allows the loop to increment 3 bytes at a time.

Speedup is around 60% on Art according to some ad-hoc benchmarking.
2015-02-12 12:46:58 +00:00
Oliver Woodman
3568ecaf00 Split TsExtractor into multiple files.
There's no code change here at all, except for how TsExtractor's
getLargestSampleTimestamp method works.
2015-02-12 12:09:57 +00:00
Oliver Woodman
92f085bc58 Remove intermediate copy steps in TsExtractor.
1. AdtsReader would previously copy all data through an intermediate
adtsBuffer. This change eliminates the additional copy step, and
instead copies directly into Sample objects.

2. PesReader would previously accumulate a whole packet by copying
multiple TS packets into an intermediate buffer. This change
eliminates this copy step. After the change, TS packet buffers
are propagated directly to PesPayloadReaders, which are required
to handle partial payload data correctly. The copy steps in the
extractor are simplified from:

DataSource->Ts_BitArray->Pes_BitArray->Sample->SampleHolder

To:

DataSource->Ts_BitArray->Sample->SampleHolder

Issue: #278
2015-02-11 14:57:07 +00:00
Oliver Woodman
797fa7f872 Make TsExtractor use ParsableByteArray where possible.
- TsExtractor is now based on ParsableByteArray rather than BitArray.
  This makes is much clearer that, for the most part, data is byte
  aligned. It will allow us to optimize TsExtractor without worrying
  about arbitrary bit offsets.
- BitArray is renamed ParsableBitArray for consistency, and is now
  exclusively for bit-stream level reading.
- There are some temporary methods in ParsableByteArray that should be
  cleared up once the optimizations are in place.

Issue: #278
2015-02-10 22:13:01 +00:00