Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public static ItagItem getItag(final int itagId) throws ParsingException {
public static final int AUDIO_CHANNELS_NOT_APPLICABLE_OR_UNKNOWN = -1;
public static final long CONTENT_LENGTH_UNKNOWN = -1;
public static final long APPROX_DURATION_MS_UNKNOWN = -1;
public static final long LAST_MODIFIED_UNKOWN = -1;

/*//////////////////////////////////////////////////////////////////////////
// Constructors and misc
Expand Down Expand Up @@ -266,6 +267,9 @@ public MediaFormat getMediaFormat() {
private AudioTrackType audioTrackType;
@Nullable
private Locale audioLocale;
private boolean isDrc;
private long lastModified;
private String xtags;

public int getBitrate() {
return bitrate;
Expand Down Expand Up @@ -647,4 +651,77 @@ public Locale getAudioLocale() {
public void setAudioLocale(@Nullable final Locale audioLocale) {
this.audioLocale = audioLocale;
}

/**
* Whether the audio is using dynamic range compression (DRC).
*
* <p>
* https://en.wikipedia.org/wiki/Dynamic_range_compression
* </p>
*
* @return whether the audio is using DRC
*/
public Boolean isDrc() {
return isDrc;
}

/**
* Sets whether the audio is using dynamic range compression (DRC).
*
* <p>
* https://en.wikipedia.org/wiki/Dynamic_range_compression
* </p>
*
* @param isDrc whether the audio has DRC applied
*/
public void setIsDrc(final Boolean isDrc) {
this.isDrc = isDrc;
}


/**
* When the stream was last modified.
*
* <p>
* If the timestamp is unknown, {@link #LAST_MODIFIED_UNKOWN} is returned.
* </p>
*
* @return unix timestamp of when the stream was last modified or
* {@link #LAST_MODIFIED_UNKOWN} if the timestamp is unknown.
*/
public long getLastModified() {
return lastModified;
}
Comment on lines +682 to +694
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a LAST_MODIFIED_UNKNOWN constant and document its use here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, though I don't think that is necessary, since every format always has a lastModified field.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, ok. I didn't know that, I just saw that there was a fallback value and thought that having documentation for it might be useful.


/**
* Sets the timestamp when the stream was last modified.
*
* @param lastModified unix timestamp of when the stream was last modified
*/
public void setLastModified(final long lastModified) {
this.lastModified = lastModified;
}

/**
* Extra tags about the stream.
*
* <p>
* Contains a Base64 encoded protobuf key-value list of additional tags for the stream,
* such as whether the stream is using {@link #isDrc()}.
* </p>
*
* @return Base64-encoded extra tags.
*/
public String getXtags() {
return xtags;
}

/**
* Sets extra tags of the stream.
*
* @param xtags extra tags of the stream
*/
public void setXtags(final String xtags) {
this.xtags = xtags;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,9 @@ private ItagInfo buildAndAddItagInfoToList(
itagItem.setIndexEnd(Integer.parseInt(indexRange.getString("end", "-1")));
itagItem.setQuality(formatData.getString("quality"));
itagItem.setCodec(codec);
itagItem.setIsDrc(formatData.getBoolean("isDrc", false));
itagItem.setLastModified(Long.parseLong(formatData.getString("lastModified", "-1")));
itagItem.setXtags(formatData.getString("xtags"));

if (streamType == StreamType.LIVE_STREAM || streamType == StreamType.POST_LIVE_STREAM) {
itagItem.setTargetDurationSec(formatData.getInt("targetDurationSec"));
Expand Down