public class BlankAudioDataSource extends java.lang.Object implements DataSource
DataSource that provides a silent audio track of the a specific duration.
This class can be used to concatenate a DataSources that has a video track only with another
that has both video and audio track.DataSource.Chunk| Constructor and Description |
|---|
BlankAudioDataSource(long durationUs) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canReadTrack(TrackType type)
Returns true if we can read the given track at this point.
|
long |
getDurationUs()
Returns the video total duration in microseconds.
|
double[] |
getLocation()
Metadata information.
|
int |
getOrientation()
Metadata information.
|
long |
getReadUs()
Returns the total number of microseconds that have been read until now.
|
android.media.MediaFormat |
getTrackFormat(TrackType type)
Called before starting to inspect the input format for this track.
|
boolean |
isDrained()
When this source has been totally read, it can return true here to
notify an end of input stream.
|
void |
readTrack(DataSource.Chunk chunk)
Called to read contents for the current track type.
|
void |
releaseTrack(TrackType type)
Called to release resources for a given track.
|
void |
rewind()
Rewinds this source, moving it to its default state.
|
long |
seekTo(long desiredTimestampUs)
Moves all selected tracks to the specified presentation time.
|
void |
selectTrack(TrackType type)
Called before starting, but after
DataSource.getTrackFormat(TrackType),
to select the given track. |
public int getOrientation()
DataSourcegetOrientation in interface DataSource@Nullable public double[] getLocation()
DataSourcegetLocation in interface DataSourcepublic long getDurationUs()
DataSourcegetDurationUs in interface DataSource@Nullable
public android.media.MediaFormat getTrackFormat(@NonNull
TrackType type)
DataSourcegetTrackFormat in interface DataSourcetype - track typepublic void selectTrack(@NonNull
TrackType type)
DataSourceDataSource.getTrackFormat(TrackType),
to select the given track.selectTrack in interface DataSourcetype - track typepublic long seekTo(long desiredTimestampUs)
DataSourceDataSource.getDurationUs().
The actual timestamp might differ from the desired one because of
seeking constraints (e.g. seek to sync frames).seekTo in interface DataSourcedesiredTimestampUs - requested timestamppublic boolean canReadTrack(@NonNull
TrackType type)
DataSourceDataSource.readTrack(Chunk) call.canReadTrack in interface DataSourcetype - track typepublic void readTrack(@NonNull
DataSource.Chunk chunk)
DataSourceDataSource.Chunk.buffer, and the
other chunk flags should be filled.readTrack in interface DataSourcechunk - output chunkpublic long getReadUs()
DataSourcegetReadUs in interface DataSourcepublic boolean isDrained()
DataSourceisDrained in interface DataSourcepublic void releaseTrack(@NonNull
TrackType type)
DataSourcereleaseTrack in interface DataSourcetype - track typepublic void rewind()
DataSourceDataSource.getReadUs() should be 0
- DataSource.isDrained() should be false
- DataSource.readTrack(Chunk) should return the very first bytesrewind in interface DataSource