text 1
30 |text 1
17 |text 2
20 |text 3
23 |two values
26 |leading dot
29 |empty
8 |invalid
8 |invalid
11 |invalid dot
14 |no unit
8 |text 1
20 |text 2
28 |text 1
25 |text 2
33 |text 1
28 |text 2
31 |text 2.5
34 |text 3
38 |text 4
41 |text 5
44 |text 1
20 |text 1
15 |text 2
23 |lorem
19 |ipsum
20 |dolor
21 |amet
22 |She first said this
25 |Then this
26 |Finally this
27 |text 1
16 |text 1
19 |21 | * Where possible, the cause returned by {@link #getCause()} will indicate the reason for failure. 22 | */ 23 | public final class ExoPlaybackException extends Exception { 24 | 25 | /** 26 | * True if the cause (i.e. the {@link Throwable} returned by {@link #getCause()}) was only caught 27 | * by a fail-safe at the top level of the player. False otherwise. 28 | */ 29 | public final boolean caughtAtTopLevel; 30 | 31 | public ExoPlaybackException(String message) { 32 | super(message); 33 | caughtAtTopLevel = false; 34 | } 35 | 36 | public ExoPlaybackException(Throwable cause) { 37 | super(cause); 38 | caughtAtTopLevel = false; 39 | } 40 | 41 | public ExoPlaybackException(String message, Throwable cause) { 42 | super(message, cause); 43 | caughtAtTopLevel = false; 44 | } 45 | 46 | /* package */ ExoPlaybackException(Throwable cause, boolean caughtAtTopLevel) { 47 | super(cause); 48 | this.caughtAtTopLevel = caughtAtTopLevel; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /library/src/main/java/com/google/android/exoplayer/ExoPlayerLibraryInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.android.exoplayer; 17 | 18 | /** 19 | * Information about the ExoPlayer library. 20 | */ 21 | public final class ExoPlayerLibraryInfo { 22 | 23 | /** 24 | * The version of the library, expressed as a string. 25 | */ 26 | public static final String VERSION = "1.5.8"; 27 | 28 | /** 29 | * The version of the library, expressed as an integer. 30 | *
31 | * Three digits are used for each component of {@link #VERSION}. For example "1.2.3" has the 32 | * corresponding integer version 1002003 (001-002-003), and "123.45.6" has the corresponding 33 | * integer version 123045006 (123-045-006). 34 | */ 35 | public static final int VERSION_INT = 1005008; 36 | 37 | /** 38 | * Whether the library was compiled with {@link com.google.android.exoplayer.util.Assertions} 39 | * checks enabled. 40 | */ 41 | public static final boolean ASSERTIONS_ENABLED = true; 42 | 43 | /** 44 | * Whether the library was compiled with {@link com.google.android.exoplayer.util.TraceUtil} 45 | * trace enabled. 46 | */ 47 | public static final boolean TRACE_ENABLED = true; 48 | 49 | private ExoPlayerLibraryInfo() {} 50 | 51 | } 52 | -------------------------------------------------------------------------------- /library/src/main/java/com/google/android/exoplayer/MediaClock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.android.exoplayer; 17 | 18 | /** 19 | * Tracks the progression of media time. 20 | */ 21 | public interface MediaClock { 22 | 23 | /** 24 | * @return The current media position in microseconds. 25 | */ 26 | long getPositionUs(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /library/src/main/java/com/google/android/exoplayer/MediaFormatHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.android.exoplayer; 17 | 18 | import com.google.android.exoplayer.drm.DrmInitData; 19 | 20 | /** 21 | * Holds a {@link MediaFormat} and corresponding drm scheme initialization data. 22 | */ 23 | public final class MediaFormatHolder { 24 | 25 | /** 26 | * The format of the media. 27 | */ 28 | public MediaFormat format; 29 | /** 30 | * Initialization data for drm schemes supported by the media. Null if the media is not encrypted. 31 | */ 32 | public DrmInitData drmInitData; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /library/src/main/java/com/google/android/exoplayer/ParserException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.android.exoplayer; 17 | 18 | import java.io.IOException; 19 | 20 | /** 21 | * Thrown when an error occurs parsing media data. 22 | */ 23 | public class ParserException extends IOException { 24 | 25 | public ParserException() { 26 | super(); 27 | } 28 | 29 | public ParserException(String message) { 30 | super(message); 31 | } 32 | 33 | public ParserException(Throwable cause) { 34 | super(cause); 35 | } 36 | 37 | public ParserException(String message, Throwable cause) { 38 | super(message, cause); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /library/src/main/java/com/google/android/exoplayer/chunk/ChunkOperationHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.android.exoplayer.chunk; 17 | 18 | /** 19 | * Holds a chunk operation, which consists of a either: 20 | *
26 | * Currently only supports parsing of a single text track.
27 | */
28 | public final class Tx3gParser implements SubtitleParser {
29 |
30 | @Override
31 | public boolean canParse(String mimeType) {
32 | return MimeTypes.APPLICATION_TX3G.equals(mimeType);
33 | }
34 |
35 | @Override
36 | public Subtitle parse(byte[] bytes, int offset, int length) {
37 | String cueText = new String(bytes, offset, length);
38 | return new Tx3gSubtitle(new Cue(cueText));
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/library/src/main/java/com/google/android/exoplayer/text/tx3g/Tx3gSubtitle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.google.android.exoplayer.text.tx3g;
17 |
18 | import com.google.android.exoplayer.text.Cue;
19 | import com.google.android.exoplayer.text.Subtitle;
20 | import com.google.android.exoplayer.util.Assertions;
21 |
22 | import java.util.Collections;
23 | import java.util.List;
24 |
25 | /**
26 | * A representation of a tx3g subtitle.
27 | */
28 | /* package */ final class Tx3gSubtitle implements Subtitle {
29 |
30 | private final List
21 | * The allocation's length is obtained by calling {@link Allocator#getIndividualAllocationLength()}
22 | * on the {@link Allocator} from which it was obtained.
23 | */
24 | public final class Allocation {
25 |
26 | /**
27 | * The array containing the allocated space. The allocated space may not be at the start of the
28 | * array, and so {@link #translateOffset(int)} method must be used when indexing into it.
29 | */
30 | public final byte[] data;
31 |
32 | private final int offset;
33 |
34 | /**
35 | * @param data The array containing the allocated space.
36 | * @param offset The offset of the allocated space within the array.
37 | */
38 | public Allocation(byte[] data, int offset) {
39 | this.data = data;
40 | this.offset = offset;
41 | }
42 |
43 | /**
44 | * Translates a zero-based offset into the allocation to the corresponding {@link #data} offset.
45 | *
46 | * @param offset The zero-based offset to translate.
47 | * @return The corresponding offset in {@link #data}.
48 | */
49 | public int translateOffset(int offset) {
50 | return this.offset + offset;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/library/src/main/java/com/google/android/exoplayer/upstream/DataSink.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.google.android.exoplayer.upstream;
17 |
18 | import java.io.IOException;
19 |
20 | /**
21 | * A component that consumes media data.
22 | */
23 | public interface DataSink {
24 |
25 | /**
26 | * Opens the {@link DataSink} to consume the specified data. Calls to {@link #open(DataSpec)} and
27 | * {@link #close()} must be balanced.
28 | *
29 | * @param dataSpec Defines the data to be consumed.
30 | * @return This {@link DataSink}, for convenience.
31 | * @throws IOException
32 | */
33 | public DataSink open(DataSpec dataSpec) throws IOException;
34 |
35 | /**
36 | * Closes the {@link DataSink}.
37 | *
38 | * @throws IOException
39 | */
40 | public void close() throws IOException;
41 |
42 | /**
43 | * Consumes the provided data.
44 | *
45 | * @param buffer The buffer from which data should be consumed.
46 | * @param offset The offset of the data to consume in {@code buffer}.
47 | * @param length The length of the data to consume, in bytes.
48 | * @throws IOException
49 | */
50 | public void write(byte[] buffer, int offset, int length) throws IOException;
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/library/src/main/java/com/google/android/exoplayer/upstream/TransferListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.google.android.exoplayer.upstream;
17 |
18 | /**
19 | * Interface definition for a callback to be notified of data transfer events.
20 | */
21 | public interface TransferListener {
22 |
23 | /**
24 | * Invoked when a transfer starts.
25 | */
26 | void onTransferStart();
27 |
28 | /**
29 | * Called incrementally during a transfer.
30 | *
31 | * @param bytesTransferred The number of bytes transferred since the previous call to this
32 | * method (or if the first call, since the transfer was started).
33 | */
34 | void onBytesTransferred(int bytesTransferred);
35 |
36 | /**
37 | * Invoked when a transfer ends.
38 | */
39 | void onTransferEnd();
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/library/src/main/java/com/google/android/exoplayer/upstream/UriDataSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.google.android.exoplayer.upstream;
17 |
18 | /**
19 | * A component that provides media data from a URI.
20 | */
21 | public interface UriDataSource extends DataSource {
22 |
23 | /**
24 | * When the source is open, returns the URI from which data is being read.
25 | *
26 | * If redirection occurred, the URI after redirection is the one returned.
27 | *
28 | * @return When the source is open, the URI from which data is being read. Null otherwise.
29 | */
30 | String getUri();
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/library/src/main/java/com/google/android/exoplayer/upstream/cache/CacheEvictor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.google.android.exoplayer.upstream.cache;
17 |
18 | /**
19 | * Evicts data from a {@link Cache}. Implementations should call {@link Cache#removeSpan(CacheSpan)}
20 | * to evict cache entries based on their eviction policies.
21 | */
22 | public interface CacheEvictor extends Cache.Listener {
23 |
24 | /**
25 | * Invoked when a writer starts writing to the cache.
26 | *
27 | * @param cache The source of the event.
28 | * @param key The key being written.
29 | * @param position The starting position of the data being written.
30 | * @param length The maximum length of the data being written.
31 | */
32 | void onStartFile(Cache cache, String key, long position, long length);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/library/src/main/java/com/google/android/exoplayer/upstream/cache/NoOpCacheEvictor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.google.android.exoplayer.upstream.cache;
17 |
18 |
19 | /**
20 | * Evictor that doesn't ever evict cache files.
21 | *
22 | * Warning: Using this evictor might have unforeseeable consequences if cache
23 | * size is not managed elsewhere.
24 | */
25 | public final class NoOpCacheEvictor implements CacheEvictor {
26 |
27 | @Override
28 | public void onStartFile(Cache cache, String key, long position, long length) {
29 | // Do nothing.
30 | }
31 |
32 | @Override
33 | public void onSpanAdded(Cache cache, CacheSpan span) {
34 | // Do nothing.
35 | }
36 |
37 | @Override
38 | public void onSpanRemoved(Cache cache, CacheSpan span) {
39 | // Do nothing.
40 | }
41 |
42 | @Override
43 | public void onSpanTouched(Cache cache, CacheSpan oldSpan, CacheSpan newSpan) {
44 | // Do nothing.
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/library/src/main/java/com/google/android/exoplayer/util/Clock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.google.android.exoplayer.util;
17 |
18 | /**
19 | * An interface through which system clocks can be read. The {@link SystemClock} implementation
20 | * must be used for all non-test cases.
21 | */
22 | public interface Clock {
23 |
24 | /**
25 | * Returns {@link android.os.SystemClock#elapsedRealtime}.
26 | *
27 | * @return Elapsed milliseconds since boot.
28 | */
29 | long elapsedRealtime();
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/library/src/main/java/com/google/android/exoplayer/util/Predicate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2014 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.google.android.exoplayer.util;
17 |
18 | /**
19 | * Determines a true of false value for a given input.
20 | *
21 | * @param