It is not always possible to align segment duration to target duration
exactly. For example, for AAC with sampling rate of 44100, there are
always 1024 audio frames per sample, so the sample duration is
1024/44100. For a target duration of 2 seconds, the closest segment
duration would be 1.984 or 2.00533.
This feature allows MPD generator to treat these segments as having
the same duration, thus allows MPD generator to generate less
SegmentTimeline entries and potentially no SegmentTimeline entries
(replaced with SegmentTemplate@duration instead if
--segment_template_constant_duration flag is enabled).
Under flag --allow_approximate_segment_timeline. Disabled by default.
Fixes#330.
Change-Id: I5044eaa348ebbf45bf792a2af53fc95a115ae21b
Removed the logic in MuxerListener to estimate bandwidth from file
size and duration, since it is not compliant to the spec.
MpdBuilder will estimate bandwidth from segment size and duration
if bandwidth is not specified in MediaInfo.
Here is the statement from DASH spec (23009-1:2014):
Consider a hypothetical constant bitrate channel of
bandwidth with the value of this attribute in bits per second
(bps). Then, if the Representation is continuously delivered
at this bitrate, starting at any SAP that is indicated either by
@startwithsap or by any Segment Index box, a client can
be assured of having enough data for continuous playout
providing playout begins after @minbuffertime *
@bandwidth bits have been received (i.e. at time
@minbuffertime after the first bit is received).
For dependent Representations this value specifies the
bandwidth according to the above definition for the
aggregation of this Representation and all complementary
Representations.
Fixes#376.
Change-Id: I0fddce39e709d0cded0a4c9ae59adbbcc97ec5ea
The file_name fields will be used to solely indicate file paths on the
designated file system, and they are used to do normal file operations,
including file creation, file updating and file removal if needed;
added new xxx_url fields, for the URLs that should appear on DASH
manifest or HLS playlists.
xxx_url are the URIs of the media in the manifest. The fields are
converted from file_name fields but adjusted to be relative to DASH
manifest path or HLS playlist path, optionally with base_url prepended.
Previously the file_name fields are converted in place to indicate
URLs when passing to manifest / playlist builders. The original file
names were lost, which made it difficult to remove files outside of
live window.
Now that the input file names are preserved. File system APIs can
operate on the original file names while manifest / playlist generation
functions can operate on URLs.
Issue: #233
Change-Id: I36a64f16e3d1261ce91783a86588f24ad1371662
According to DASH spec (23009-1:2014):
Consider a hypothetical constant bitrate channel of
bandwidth with the value of this attribute in bits per second
(bps). Then, if the Representation is continuously delivered
at this bitrate, starting at any SAP that is indicated either by
@startwithsap or by any Segment Index box, a client can
be assured of having enough data for continuous playout
providing playout begins after @minbuffertime *
@bandwidth bits have been received (i.e. at time
@minbuffertime after the first bit is received).
For dependent Representations this value specifies the
bandwidth according to the above definition for the
aggregation of this Representation and all complementary
Representations.
This suggests that max bitrate should be used instead of average
bitrate.
Also cleaned up BandwidthEstimator code.
Fixes#376.
Change-Id: Ibf5896394c5c6bb820849771a2129c59202d2273
Two-character ISO-639 code in --default_language was ignored due to
a bug in language code matching as the language code in stream is
always converted to 3-character code.
Fixes#371.
Change-Id: I8618938af583a417446636ff9efe1c72ce822c33
This flag was introduced to workaround a rounding error in Chrome
(probably in other browsers too).
Also although this flag avoids the first frame of a Period to be
dropped due to rounding error but it could cause the last frame of a
Period to be dropped.
Now that we use a high precision Period@duration, we do not expect to
see rounding errors any more. The player would be a better place for
the workaround even if it is still needed.
Related issue: #368.
Change-Id: I3bd517ecc6d548ff62e0c13394edb49d4bc68e8f
Instead, the actual earliest presentation time is used except for
the first segment if there is an offset between presentation time
(pts) and decoding time (dts).
Chrome (as of v66) reports dts instead of pts in buffered ranges in
MSE API. To avoid breaking Chrome, the earliest_presentation_time
of the first segment is set to its dts as Chrome does not like negative
values for
adjusted dts = dts + Period@start (0 for the first period)
- presentationTimeOffset (earliest_presentation_time).
Fixes#303.
Change-Id: I5ca80e05d5570961400499436f2bcc01f06e69e0
UTCTiming schemeIdUri and value pairs can be provided to packager using
--utc_timings flag. It should be comma separated list of
schemeIdUri=value pairs.
Note that urn:mpeg:dash:utc:direct:2014 scheme is not supported as it
requires the MPD to be dynamically generated on the fly when MPD is
served to client.
Fixes#311.
Change-Id: Ibc07af8a6d8b2b6261ba3ecd2c02f23809f96614
Chrome internally uses time accurate to microseconds, which is
implemented per MSE spec (https://www.w3.org/TR/media-source/).
Generate Period@duration with better precision to avoid possible
buffered range gaps in Chrome (possibly other browsers too), which
may lead to other problems like playback stall.
b/74238961
Fixes#368.
Change-Id: I357a0f62b67f75c7ca044bb99ea4e3c8bbb6fecd
It is now managed in SimpleMpdNotifier.
This avoids unnecessary increment in AdaptationSet id counter.
Also makes sure the AdaptationSet is sorted by id in XML output.
Change-Id: Ibcd0b047a71c19cd30ad7d8af9a2ed0bb05e043e
Prefer timestamps from Video AdaptationSets if available - this avoids
possible video playback jitters due to gaps.
presentationTimeOffset is not applied to the first period as it may in
negative dts which Chrome does not like: https://crbug.com/398141.
It is safe to apply to subsequent periods as the actual offset applied
takes Period@start into consideration:
offset = Period@start - presentationTimeOffset
The result timestamp with offset applied is close to Period@start, so
it is unlikely to result in a negative dts value.
Closes b/73899306.
Change-Id: If8361f5469610093b3aac6675754536ad7e83c4c
This change has the hls master playlist add the text codec string
to the list of codecs in a variant.
Bug: 72942756
Change-Id: Ib25bb2064a291d10d7b1d261a4307991df62220c
There could be rounding errors in MSE which could cut the first key
frame of the representation and thus cut all the frames until the next
key frame, which then leads to a big gap in presentation
timeline which stalls playback.
Adjusting presentationTimeOffset (PTO) by -1, i.e. backing off PTO by 1
to compensate for the possible rounding error. It should not cause any
playback issues as it is small enough. The workaround can be removed
once the problem is handled in all players.
The PTO adjustment is configurable with command line flag:
--pto_adjustment, with value set to -1 by default.
b/71808910
Change-Id: I9c4d1e2ee84008b859a3638a8146c910cead1f15
Also added Period::GetAdaptationSets and
AdaptationSet::GetRepresentations.
Instead of implementing GetDurationSeconds in all MpdBuilder classes
(MpdBuilder/Period/Adaptation/Representation) like what we used to do
with GetEarliestTimestamp, the two new functions allows MpdBuilder to
iterate through the Representations to get durations.
Also updates GetEarliestTimestamp functions to use the same iteration
method.
Change-Id: I682b70c07c248c0f6511ec3d9019086f986ee10e
- Update curl to 7.57.0
- Roll clang, which is needed due to MacOS / XCode update
- Fixes and suppress compilation errors due to clang update
Fixes#285
Change-Id: Ibac3288c641861605c3c0500d34d27373e6eecfe
Move AdaptationSet related functions to the new Period class, which
maps to <Period> element and provides methods to add AdaptationSets.
Change-Id: I0fee290769fbe9a6355cc1b8c86baec8fbc4b4fd
Clean up DashIopMpdNotifier to make it easier to add Period class.
- Consolidate protected AdaptationSet grouping related logic to the
internal ProtectedAdaptationSetMap class
- Clean up AdaptationSet creation logic and updating logic
Change-Id: Idd5b39bb89d38e490ca4f561a6b840ccc9f1e40a
Moved from mpd_unittest.cc to representation_unittest.cc.
Also removed unused test data files in packager/mpd/test/data.
Change-Id: I23811390b4b1ffbfac3e69c1ffcf92544099a53d
Move AdaptationSet related tests to adaptation_set_unittest.cc and
Representation related tests to representation_unittest.cc.
Change-Id: I360e9aea3ba08a32e5ba3b0e8b34345f2b3f0b20
Added gMock matchers for matching xmlNodePtr and its attributes.
Clean up mpd_unittests to make it easier to separate adaptation set
tests and representation tests.
Change-Id: I31816b06e9c76f92d4a82656c659f3b9acae8cb5
Problem occurs when the media playlists are in a sub-directory under
master playlist. If base_url is not set, media segment URL should be
relative to the media playlist instead of the master playlist.
Also make sure the path separator is "/" in URL instead of "\" on
Windows.
Fixes#253
Change-Id: I8e933750276435d94dd01bfa53ee2bc050dfd193
In the original manifest updating process, the file was truncated first
before was written with new contents. There is a small chance that
the web server may read back empty file or incomplete file.
The new code makes the update operation atomic (by writing to a temporary
file first then replace the old file with the temporary file).
Fixes#186
Change-Id: I2fd564cb12b922b032c0e9f70d2132a5b12ff098
frame_duration is not available when the VideoInfo is created, but
it will become available when a media segment arrives.
Change-Id: I2c24852fca4ff77c2b86ff78dbf0963ad0a0afa6
'availability_time_offset' is not an attribute in MPD specification,
but used to calculate availability_start_time to adjust segment
availability time. A similar effect can be achieved with standard
blessed suggested_presentation_delay flag.
If suggested_presentation_delay is not set, player is expected to
choose a suitable value.
Change-Id: I1d540bd4347b4f04b6cc5ec0778e1a5392009b09
This is a fix for issue #216 where the Representation::SlideWindow() logic was
still active even though a static MPD was being asked to be generated (using
the option -generate_static_mpd). This could cause static streams longer than
1800 seconds to start playing at (end-position-for-stream - 1800 seconds).
This change is in compliance with the current usage documentation for the
shaka-packager, which suggests that -time_shift_buffer_depth only is relevant
for dynamic media presentations.
Before this, HLS output did not contain language information.
Now, media playlists are properly tagged with a language in the
master playlist.
b/36134267
Change-Id: I172e946dbedd096a44cb2f917b007cc004756228
- Added two new fields in MpdOptions: dash_profile and mpd_type
- Updated MpdBuilder to support LiveProfile with static mpd
- Command line arguments will be updated in the next CL
Issue #142
Change-Id: Ibd35e5c9e1b1ef98043392e3f04a0af4700135c1
Current mechanism of using AdaptationSet @group is not spec compliant.
The spec compliant mechanism is to use supplemental descriptor with
schemeIdUri: urn:mpeg:dash:adaptation-set-switching:2016 as specified
in ISO/IEC 23009-1:2014/Amd.4:2016.
Fixes#156
Change-Id: I4d97648547a23315ba9c09dcadb14e18c99a45fc
Setting this flag will tag any matching tracks with kRoleMain.
The player will then know which tracks should be default when there
is not a language match.
Closes#155
Change-Id: I827304c49e345d07b1e76f7a46421b60f228f0ba
1. Replace STLDeleter with unique_ptr in container, which is
supported in C++11
2. Replace string_as_array with &string[0] which is guaranteed
to work in C++11
Change-Id: I7f39c0e51fc8a3fcbb41313094a0ca6b33db7bf3
* EncryptionKey now contains them rather than a PSSH box.
* Outputs PSSH boxes for each entry.
* Outputs a ContentProtection element for each entry.
* Removed SystemName and UUID from KeySource.
* Removed --scheme_id_uri packager argument.
Issue #88
Change-Id: I2651784c3220fd64f5b1773fdcd70285690cf8c0
This adds a new function to key AdaptationSets based on the
characteristics that require separate sets.
With this, we are now able to package multi-codec assets at once
(AVC1/MP4 and VP9/WebM in the same manifest, but in different
AdaptationSets).
Fixes b/27534371
Change-Id: Ie82fd096d2ef99fd23e323d60fd0849b1e8d7500
When normalizing language tags to their shortest form, we need to
split off subtags and treat them as separate components that do not
get changed.
Furthermore, MP4 can only store language tags without subtags. So
only store the main language in MP4 output.
Fixes b/27533973
Change-Id: I96049e274aae9841e321c53039ef6464a2e61574
Parse channel layout value from dec3 box. Pass it through audio stream
info. MPD builder forms audio channel configuration to signal ec-3
codec.
Specs: 1) ETSI TS 102 366 V1.3.1 Digital Audio Compression (AC-3,
Enhanced AC-3) Standard E.1.3.1.8.
2) DASH-IF Interoperability Points v3.0 9.2.1.2.
Issue #64
Change-Id: Ia2c22dd3d82e757ba5a88ba1de35c5d593f5005e
Now outputs cenc:default_KID attributes on all ContentProtection
elements for non-MP4 streams. For MP4 streams, it will still output
the default ContentProtection element.
Closes#69
Change-Id: I38b24297aa3c2ccbcbde38b44279b56c37a388f7
- From DASH spec 2014, MPD@publishTime and Period@id are required for
'dynamic' MPD.
- Period@id is always set to "0".
- MPD@publishTime is set to the time when the MPD is output.
Issue #55
Change-Id: I5e50aa11067176e69a2343fbc82ca42129703e1b
- @width, @height, @frameRate for Representation element will not be
set if the attributes are set at AdaptationSet level.
Issue #55
Change-Id: Ib4e669142874f9e8f0ca773df9f87a3fef01b729
For mp4 outputs, a metadata box with version information is added to
moov box.
For mpd outputs, a text comment with version information is added in
the beginning of mpd file.
Issue #60
Change-Id: I783ba370781c0a8f77c910ff1172bad2e7edff75
- Replaced urn:mpeg:DASH:schema:MPD:2011 with
urn:mpeg:dash:schema:mpd:2011. The former is from the old spec.
- Replaced the MPD schema with the latest one.
- Fixed subSegmentAlignment typo with subsegmentAlignment.
Issue #55
Change-Id: Icffa9872ffc462627b81900a48f59e7b76687c11
- Since most use cases use notifier implementations that already uses
locks, removing locks from MpdBuilder.
- Added locks to MpdNotifier::Flush() implementations. Multiple threads
were able to write to the same file.
Issue #45, #49
Change-Id: I6e39824485672f40e6c947da97f1743fac174167
- Added factory methods for creating Representation and AdaptationSet in
tests.
- Since most tests only needed access to the constructors for
Representation and AdaptationSet, instead of using
FRIEND_TEST_ALL_PREFIXES() for each test case, added factory methods
on the test class.
- Check the 'frameRate' attribute in
CommonMpbBuilderTest.SetSampleDuration.
Change-Id: I57bd3a90b397f90c3a3a91de03eb96000f58ef58
- Neither live with or without key rotation did not output the right
result.
- No key rotation: did not produce any ContentProtection element.
- With key rotation: did not have DRM specific ContentProtection.
- To get key rotation working with shaka player, <cenc:pssh> elements
are removed.
Change-Id: I1f34d303ae1f3ea81820e3368ab66b8420498372
- ContentProtection elements were missing when using MpdWriter,
therefore mpd_generator also did not generate ContentProtection.
- MpdWriter uses MpdNotifier now, instead of directly using MpdBuiler.
- Add mock_mpd_notifier.{h,cc} to be shared by several tests.
Change-Id: Id0f6213aa0c80e50294cd4193962054b0b5c2492
- Because MpdBuilder no longer sets ContentProtection, live was broken.
- For key-rotation, <cenc:pssh> element is updated.
Change-Id: I45bb80a12faff39ccf5deb82439c0732ed9cea59
- Without the Flush() method the implementation had to do writes in
almost all methods. Usually the user of the notifier knows when to
write out the MPD.
Change-Id: Ic165d4594f01357a8ac7e8501eefa0f85c08d32f
- SimpleMpdNotifier didn't register the container ID to its map for VOD.
- AddContentProtection() was not implemented.
Change-Id: I5f1412c785ee5ad3d00910755ff283c404dd895c
Quotient reduction to minimal form does not work well in practice due to
rounding of the inputs.
Bug: 23432995
Change-Id: If333ab48accb7f6a3fac6ba4eb48ca7b9cee9826
- subSegmentAlignment logic assumed that all Representations were
added before calling Representations::AddNewSegment() on any
Representation in an AdaptationSet. It is not a valid assumption
for VOD and is removed.
Change-Id: Ifb7e34ee103ee30027e45a804427baf281f3137c
- AdaptationSet::OnNewSegmentForRepresentation() calculates whether the
Representations are aligned by looking at the start time and duration.
(Except that duration is not used in this implementation).
- Add RepresentationStateChangeListener to callback
AdaptationSet::OnNewSegmentForRepresentation() from Representation.
Change-Id: I3c30bd6652880dabb9d5c619d8a733ffc789eec9
- ContentProtection elements should be added explicitly by the
AddContentProtection() methods.
- This is because some MPDs should have ContentProtection at
AdaptationSet level instead of Representation.
- Change SimpleMpdNotifier, which uses MpdBuilder, to add
ContentProtectionElements. The logic is moved from MuxerListener.
- Add Element class for specifying subelements for
ContentProtectionElement.
Change-Id: I9bedfb3e5a5ac0b3d5c702f1e6e4a8608c978d1d
- The UUID and DRM name can be fetched from KeySource.
- Add ProtectedContent message to MediaInfo. The message contains basic
information for the protected content, such as the default key ID for
the content.
- The message is required to separate Representations with different
content protection information into different AdaptationSets.
Change-Id: Ib9dc834ae0abf93b7ca0acdf52a865b1394a4816
- Pass pixel_height and pixel_width from VideoStreamInfo to MediaInfo.
- par can only be set if all the Representations have the same
picture aspect ratio. That is the ratio of sar_x*width:sar_y*height
should all be the same.
- If there is a Representation that does not have the sar attribute set,
par is also not set.
Change-Id: Id34c95e4a99da9ce028a9f35737cfe5bca9e5697