-
Notifications
You must be signed in to change notification settings - Fork 516
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
feat: convert mpd module to cmake #1234
Conversation
packager/mpd/base/mpd_builder.h
Outdated
@@ -32,6 +32,15 @@ class AdaptationSet; | |||
class MediaInfo; | |||
class Period; | |||
|
|||
class Clock { |
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.
I created this class to replace the base::Clock and be able to override it for testing. Probably needs to be moved somewhere else from mpd_builder.h though, suggestions?
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.
I had to create something similar already in Muxer in b1095f6. See packager/media/base/muxer.h.
We can always create a new folder to hold these things if we want to dedup them. I agree that this doesn't really belong in mpd.
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.
moved it to a separate file. This is used in the end to print ISO-8601 dates so I think it's better to keep this in std::tm instead of uint64_t timestamps. I updated the MuxerClock to use this Clock abstraction as well.
std::tm local_time = utc_time; | ||
std::time_t utc_time_t = std::mktime(&local_time); | ||
std::time_t offset = utc_time_t - std::mktime(std::gmtime(&utc_time_t)); | ||
mock_time_ = std::chrono::system_clock::from_time_t(utc_time_t + offset); |
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.
had to jump through some hoops to be able to specify a std:tm
in UTC for test injection. I think this works but perhaps there is a better way? The only better solutions I could find were C++20 though.
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.
In muxer, I have the clock abstraction return uint64_t in seconds since 1970 UTC. (Essentially the same as time_t.) Depending on how it is consumed, you could do the same here, and avoid time_point and std::chrono.
mpd_.InjectClockForTesting(std::unique_ptr<base::Clock>( | ||
new TestClock(base::Time::FromUTCExploded(test_time)))); | ||
std::tm test_time{}; | ||
test_time.tm_year = 2016 - 1900; // Years since 1900 |
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.
I don't like that this is the best option I could find to initialize a test time from something human readable. Worth adding some kind of helper method for this? Or is there some better solution?
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.
I tend to find ISO 8601 time strings to be pretty readable. If there's an easy way to parse those into the appropriate value type, I would use that. Ex: "2016-01-11T15:10:24Z"
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.
ok, updated TestClock to use ISO-8601 format as the input
packager/mpd/base/xml/xml_node.cc
Outdated
absl::big_endian::FromHost16(codec_data.channel_mask()); | ||
uint8_t byte1 = ec3_channel_map & 0xFF; | ||
uint8_t byte2 = ec3_channel_map >> 8; | ||
audio_channel_config_value = absl::StrFormat("%02X%02X", byte1, byte2); |
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.
couldn't find a better way to get the base::HexEncode
here in big endian format, is this the best way to proceed?
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.
Maybe add another helper to packager/utils/hex_parser. I'm not certain you need to decompose it into individual bytes if you've already done a swap with absl. Just FromHost16 and StrFormat("%04X") should be fine, right? Or FromHost16 and BytesToHexString?
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.
That's where I started and that didn't work, the byte order was reversed, but looks like I was overthinking it. StrFormat("%04X", ...)
works by itself, without FromHost16
, going to big endian order is only important if we go byte at a time like the manual formatting.
packager/mpd/base/xml/xml_node.cc
Outdated
audio_channel_config_value = | ||
base::HexEncode(&ac4_channel_mask, sizeof(ac4_channel_mask) - 1); | ||
absl::StrFormat("%02X%02X%02X", bytes[0], bytes[1], bytes[2]); |
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.
likewise here for the uint32_t
, perhaps I should the same approach for both AC3 and AC4 though.
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.
Same as above, I think. Swap and print/format/hexify without needing Span or individual bytes.
Also, it took me a while to see the "- 1" on the original. Please add a comment about us needing just 3 bytes.
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.
done
ef81fe5
to
7a83ad5
Compare
bandwidth_estimator.cc is throwing an error on windows due to narrowing conversion from double to uint64. Since this one seems quite intentional, what is the right way to do this without tripping on |
0418c29
to
b1234b8
Compare
Is this the |
48de724
to
25e89b2
Compare
std::vector<uint8_t> pssh; | ||
base::HexStringToBytes(pssh_str, &pssh); | ||
|
||
std::string pssh_hex_str = absl::HexStringToBytes(pssh_str); |
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.
I'd still like to clean this up.
media_info_.set_segment_template_url("$Number$.m4s"); | ||
} | ||
|
||
void TearDown() override { FLAGS_segment_template_constant_duration = false; } | ||
void TearDown() override { | ||
absl::SetFlag(&FLAGS_segment_template_constant_duration, false); |
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 becomes unnecessary with FlagSaver.
@@ -549,7 +550,7 @@ TEST_F(LiveSegmentTimelineTest, LastSegmentNumberSupplementalProperty) { | |||
" <SegmentTemplate media=\"$Number$.m4s\" " | |||
" startNumber=\"1\" duration=\"100\"/>" | |||
"</Representation>")); | |||
FLAGS_dash_add_last_segment_number_when_needed = false; | |||
absl::SetFlag(&FLAGS_dash_add_last_segment_number_when_needed, false); |
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 becomes unnecessary.
…library type with explicit source list
Issue #1047