-
Notifications
You must be signed in to change notification settings - Fork 506
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
Adding allow_codec_switching parameter #726
Changes from 6 commits
3ec315b
7889bf6
2fe2524
6b13b67
4344d71
2524a17
24b6d18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -447,7 +447,8 @@ def _GetFlags(self, | |
ad_cues=None, | ||
default_language=None, | ||
segment_duration=1.0, | ||
use_fake_clock=True): | ||
use_fake_clock=True, | ||
allow_codec_switching=False): | ||
flags = [] | ||
|
||
if not strip_parameter_set_nalus: | ||
|
@@ -528,6 +529,9 @@ def _GetFlags(self, | |
if generate_static_live_mpd: | ||
flags += ['--generate_static_live_mpd'] | ||
|
||
if allow_codec_switching: | ||
flags += ['--allow_codec_switching'] | ||
|
||
if ad_cues: | ||
flags += ['--ad_cues', ad_cues] | ||
|
||
|
@@ -1499,6 +1503,42 @@ def testLiveStaticProfileWithTimeInSegmentName(self): | |
self._GetFlags(output_dash=True, generate_static_live_mpd=True)) | ||
self._CheckTestResults('live-static-profile-with-time-in-segment-name') | ||
|
||
def testAllowCodecSwitching(self): | ||
streams = [ | ||
self._GetStream('video', test_file='bear-640x360-hevc.mp4'), | ||
self._GetStream('video', test_file='bear-640x360.mp4'), | ||
self._GetStream('video', test_file='bear-1280x720.mp4'), | ||
self._GetStream('audio', test_file='bear-640x360.mp4'), | ||
] | ||
|
||
self.assertPackageSuccess(streams, | ||
self._GetFlags(output_dash=True, | ||
allow_codec_switching=True)) | ||
# Mpd cannot be validated right now since we don't generate determinstic | ||
# mpd with multiple inputs due to thread racing. | ||
# TODO(b/73349711): Generate determinstic mpd or at least validate mpd | ||
# schema. | ||
# See also https://github.com/google/shaka-packager/issues/177. | ||
|
||
def testAllowCodecSwitchingWithEncryptionAndTrickplay(self): | ||
streams = [ | ||
self._GetStream('video', test_file='bear-640x360-hevc.mp4'), | ||
self._GetStream('video', test_file='bear-640x360.mp4'), | ||
self._GetStream('video', test_file='bear-1280x720.mp4'), | ||
self._GetStream('video', test_file='bear-1280x720.mp4', | ||
trick_play_factor=1), | ||
self._GetStream('audio', test_file='bear-640x360.mp4'), | ||
] | ||
|
||
self.assertPackageSuccess(streams, self._GetFlags(output_dash=True, | ||
allow_codec_switching=True, | ||
encryption=True)) | ||
# Mpd cannot be validated right now since we don't generate determinstic | ||
# mpd with multiple inputs due to thread racing. | ||
# TODO(b/73349711): Generate determinstic mpd or at least validate mpd | ||
# schema. | ||
# See also https://github.com/google/shaka-packager/issues/177. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add another variant with encryption and trick play? def testAllowCodecSwitchingWithEncryptionAndTrickplay(self):
streams = [
self._GetStream('video', test_file='bear-640x360-hevc.mp4'),
self._GetStream('video', test_file='bear-640x360.mp4'),
self._GetStream('video', test_file='bear-1280x720.mp4'),
self._GetStream('video', test_file='bear-1280x720.mp4', trick_play_factor=1),
self._GetStream('audio', test_file='bear-640x360.mp4'),
]
self.assertPackageSuccess(streams,
self._GetFlags(output_dash=True,
allow_codec_switching=True,
encryption=True))
# Mpd cannot be validated right now since we don't generate determinstic
# mpd with multiple inputs due to thread racing.
# TODO(b/73349711): Generate determinstic mpd or at least validate mpd
# schema.
# See also https://github.com/google/shaka-packager/issues/177. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooops, I forgot one additional line here in my previous comment: self._CheckTestResults(
'audio-video-with-codec-switching-encryption-trick-play',
diff_files_policy=DiffFilesPolicy(
allowed_diff_files=['output.mpd'], exact=False)) Similar for the test above: self._CheckTestResults(
'audio-video-with-codec-switching',
diff_files_policy=DiffFilesPolicy(
allowed_diff_files=['output.mpd'], exact=False)) |
||
def testLiveProfileAndEncryption(self): | ||
self.assertPackageSuccess( | ||
self._GetStreams(['audio', 'video'], segmented=True), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!--Generated with https://github.com/google/shaka-packager version <tag>-<hash>-<test>--> | ||
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT2.802799940109253S"> | ||
<Period id="0"> | ||
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" subsegmentAlignment="true" par="16:9"> | ||
<SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="1"/> | ||
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/> | ||
<Representation id="0" bandwidth="277411" codecs="hev1.1.6.L63.90" mimeType="video/mp4" sar="1:1"> | ||
<BaseURL>bear-640x360-hevc-video.mp4</BaseURL> | ||
<SegmentBase indexRange="1899-1966" timescale="30000"> | ||
<Initialization range="0-1898"/> | ||
</SegmentBase> | ||
</Representation> | ||
</AdaptationSet> | ||
<AdaptationSet id="1" contentType="video" maxWidth="1280" maxHeight="720" frameRate="30000/1001" subsegmentAlignment="true" par="16:9"> | ||
<SupplementalProperty schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" value="0"/> | ||
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/> | ||
<Representation id="1" bandwidth="2627285" codecs="avc1.64001f" mimeType="video/mp4" sar="1:1" width="1280" height="720"> | ||
<BaseURL>bear-1280x720-video.mp4</BaseURL> | ||
<SegmentBase indexRange="858-925" timescale="30000"> | ||
<Initialization range="0-857"/> | ||
</SegmentBase> | ||
</Representation> | ||
<Representation id="2" bandwidth="973483" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1" width="640" height="360"> | ||
<BaseURL>bear-640x360-video.mp4</BaseURL> | ||
<SegmentBase indexRange="859-926" timescale="30000"> | ||
<Initialization range="0-858"/> | ||
</SegmentBase> | ||
</Representation> | ||
</AdaptationSet> | ||
<AdaptationSet id="2" contentType="audio" subsegmentAlignment="true"> | ||
<Representation id="3" bandwidth="133334" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="44100"> | ||
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/> | ||
<BaseURL>bear-640x360-audio.mp4</BaseURL> | ||
<SegmentBase indexRange="793-860" timescale="44100"> | ||
<Initialization range="0-792"/> | ||
</SegmentBase> | ||
</Representation> | ||
</AdaptationSet> | ||
</Period> | ||
</MPD> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,6 +176,13 @@ class AdaptationSet { | |
/// @return true if it is a video AdaptationSet. | ||
bool IsVideo() const; | ||
|
||
/// @return codec. | ||
const std::string& codec() const { return codec_; } | ||
|
||
/// Set AdaptationSet@codec. | ||
/// @param codec is the new codec to be set. | ||
void set_codec(const std::string& codec) { codec_ = codec; }; | ||
|
||
protected: | ||
/// @param language is the language of this AdaptationSet. Mainly relevant for | ||
/// audio. | ||
|
@@ -269,6 +276,9 @@ class AdaptationSet { | |
// Determined by examining the MediaInfo passed to AddRepresentation(). | ||
std::string content_type_; | ||
|
||
// Codec of AdaptationSet. | ||
std::string codec_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also define an accessor for codec_ after line 178: /// @return codec. |
||
|
||
// This does not have to be a set, it could be a list or vector because all we | ||
// really care is whether there is more than one entry. | ||
// Contains one entry if all the Representations have the same picture aspect | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,9 @@ struct MpdParams { | |
/// SegmentTimeline if it is enabled. It will be populated from segment | ||
/// duration specified in ChunkingParams if not specified. | ||
double target_segment_duration = 0; | ||
/// If enabled, allow switching between different codecs, if they have the | ||
/// same language, media type (audio, video etc) and container type. | ||
bool allow_codec_switching = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally we don't pull changes from master, which may cause confusions to the bots as seen in this PR. I'll see if I can merge it with this later. |
||
}; | ||
|
||
} // namespace shaka | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block is not formatted correctly. Please follow either the blocks from line 49 - 52 or the blocks from line 53 - 64. Alternatively, you may need to use clang-format: https://github.com/google/shaka-packager/blob/master/packager/tools/git/check_formatting.py