Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
553a1d2e
authored
Jul 18, 2014
by
ojw28
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #16 from google/dev
Add missing files.
parents
4228f2cf
bb5cfd52
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
150 additions
and
0 deletions
library/src/main/java/com/google/android/exoplayer/dash/DashSegmentIndex.java
library/src/main/java/com/google/android/exoplayer/dash/DashWrappingSegmentIndex.java
library/src/main/java/com/google/android/exoplayer/dash/mpd/SegmentBase.java
library/src/main/java/com/google/android/exoplayer/dash/DashSegmentIndex.java
0 → 100644
View file @
553a1d2e
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
google
.
android
.
exoplayer
.
dash
;
import
com.google.android.exoplayer.dash.mpd.RangedUri
;
/**
* Indexes the segments within a media stream.
*
* TODO: Generalize to cover all chunk streaming modes (e.g. SmoothStreaming) if possible.
*/
public
interface
DashSegmentIndex
{
/**
* Returns the segment number of the segment containing a given media time.
*
* @param timeUs The time in microseconds.
* @return The segment number of the corresponding segment.
*/
int
getSegmentNum
(
long
timeUs
);
/**
* Returns the start time of a segment.
*
* @param segmentNum The segment number.
* @return The corresponding start time in microseconds.
*/
long
getTimeUs
(
int
segmentNum
);
/**
* Returns the duration of a segment.
*
* @param segmentNum The segment number.
* @return The duration of the segment, in microseconds.
*/
long
getDurationUs
(
int
segmentNum
);
/**
* Returns a {@link RangedUri} defining the location of a segment.
*
* @param segmentNum The segment number.
* @return The {@link RangedUri} defining the location of the data.
*/
RangedUri
getSegmentUrl
(
int
segmentNum
);
/**
* Returns the segment number of the first segment.
*
* @return The segment number of the first segment.
*/
int
getFirstSegmentNum
();
/**
* Returns the segment number of the last segment.
*
* @return The segment number of the last segment.
*/
int
getLastSegmentNum
();
}
library/src/main/java/com/google/android/exoplayer/dash/DashWrappingSegmentIndex.java
0 → 100644
View file @
553a1d2e
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
google
.
android
.
exoplayer
.
dash
;
import
com.google.android.exoplayer.dash.mpd.RangedUri
;
import
com.google.android.exoplayer.parser.SegmentIndex
;
import
com.google.android.exoplayer.util.Util
;
import
android.net.Uri
;
/**
* An implementation of {@link DashSegmentIndex} that wraps a {@link SegmentIndex} parsed from a
* media stream.
*/
public
class
DashWrappingSegmentIndex
implements
DashSegmentIndex
{
private
final
SegmentIndex
segmentIndex
;
private
final
Uri
uri
;
private
final
long
indexAnchor
;
/**
* @param segmentIndex The {@link SegmentIndex} to wrap.
* @param uri The {@link Uri} where the data is located.
* @param indexAnchor The index anchor point. This value is added to the byte offsets specified
* in the wrapped {@link SegmentIndex}.
*/
public
DashWrappingSegmentIndex
(
SegmentIndex
segmentIndex
,
Uri
uri
,
long
indexAnchor
)
{
this
.
segmentIndex
=
segmentIndex
;
this
.
uri
=
uri
;
this
.
indexAnchor
=
indexAnchor
;
}
@Override
public
int
getFirstSegmentNum
()
{
return
0
;
}
@Override
public
int
getLastSegmentNum
()
{
return
segmentIndex
.
length
-
1
;
}
@Override
public
long
getTimeUs
(
int
segmentNum
)
{
return
segmentIndex
.
timesUs
[
segmentNum
];
}
@Override
public
long
getDurationUs
(
int
segmentNum
)
{
return
segmentIndex
.
durationsUs
[
segmentNum
];
}
@Override
public
RangedUri
getSegmentUrl
(
int
segmentNum
)
{
return
new
RangedUri
(
uri
,
null
,
indexAnchor
+
segmentIndex
.
offsets
[
segmentNum
],
segmentIndex
.
sizes
[
segmentNum
]);
}
@Override
public
int
getSegmentNum
(
long
timeUs
)
{
return
Util
.
binarySearchFloor
(
segmentIndex
.
timesUs
,
timeUs
,
true
,
true
);
}
}
library/src/main/java/com/google/android/exoplayer/dash/mpd/SegmentBase.java
0 → 100644
View file @
553a1d2e
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment