Skip to content
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

Support timezones in ISO8601 timestamps obtained from DASH UTCTiming elements #3524

Closed
pstambrecht opened this issue Nov 30, 2017 · 7 comments
Assignees

Comments

@pstambrecht
Copy link
Contributor

pstambrecht commented Nov 30, 2017

DashMediaSource class supports only "yyyy-MM-dd'T'HH:mm:ss'Z'" date format. Only one way how to change it is implement own custom DashMediaSource class. 806 lines of implementation for 1 line change. What about enable custom date format?

private static final class Iso8601Parser implements ParsingLoadable.Parser<Long> {

    @Override
    public Long parse(Uri uri, InputStream inputStream) throws IOException {
      String firstLine = new BufferedReader(new InputStreamReader(inputStream)).readLine();
      try {
        // TODO: It may be necessary to handle timestamp offsets from UTC.
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
        format.setTimeZone(TimeZone.getTimeZone("UTC"));
        return format.parse(firstLine).getTime();
      } catch (ParseException e) {
        throw new ParserException(e);
      }
    }

  }
@pstambrecht pstambrecht changed the title DashMediaSource: Unable to set custom time format parser DashMediaSource: Unable to set custom date format parser Nov 30, 2017
@ojw28
Copy link
Contributor

ojw28 commented Nov 30, 2017

Please provide an example of a standard compliant DASH manifest containing a date in a format that our parser doesn't handle. Thanks.

@pstambrecht
Copy link
Contributor Author

In .mpd file is
<UTCTiming schemeIdUri="urn:mpeg:dash:utc:http-iso:2014" value="https://st14-4.o2tv.cz:443/get-utc-timestamp"/>

which contains URL to https://st14-4.o2tv.cz:443/get-utc-timestamp . This URL returns time in yyyy-MM-dd'T'HH:mm:ssXXX format.

@ojw28
Copy link
Contributor

ojw28 commented Nov 30, 2017

The format looks like: yyyy-MM-dd'T'HH:mm:ss<timezone-designator> to me, so this is really a request to implement the TODO in the code you reference:

// TODO: It may be necessary to handle timestamp offsets from UTC.

In this specific case the timezone looks like it's set to 0 currently, which is the same as Z, which is therefore trivial to handle. It's unclear whether your server will ever return a non-zero timezone, however. In the general case we need to handle timezones as specified here.

If you need this functionality, perhaps you could send a pull request to our dev-v2 branch that does the TODO?

@ojw28 ojw28 changed the title DashMediaSource: Unable to set custom date format parser Support timezone designators in ISO8601 timestamps (for DASH UTCTiming) Nov 30, 2017
@ojw28 ojw28 changed the title Support timezone designators in ISO8601 timestamps (for DASH UTCTiming) Support timezones in ISO8601 timestamps obtained from DASH UTCTiming elements Nov 30, 2017
@ojw28
Copy link
Contributor

ojw28 commented Nov 30, 2017

Note that if you know the timezone is always going to be 0, then you could add partial support sufficient for your use case simply by checking whether firstLine ends with "+00:00", "+0000" or "+00", and replacing with "Z" if so before parsing.

@pstambrecht
Copy link
Contributor Author

Pull request ready.... #3545

@ojw28
Copy link
Contributor

ojw28 commented Dec 4, 2017

Request merged, thanks! Leaving this open. We have a change that adds more comprehensive timezone support that we'll merge fairly soon, at which point this can be closed.

@pstambrecht
Copy link
Contributor Author

You're welcome :)

ojw28 added a commit that referenced this issue Dec 4, 2017
Issue: #3524

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177808106
@ojw28 ojw28 closed this as completed Dec 4, 2017
ojw28 added a commit that referenced this issue Dec 12, 2017
Issue: #3524

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=177808106
@google google locked and limited conversation to collaborators Apr 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants