29 | * Must be called prior to each attempt to dequeue output buffers from the decoder.
30 | *
31 | * @param positionUs The current playback position in microseconds.
32 | */
33 | void setPositionUs(long positionUs);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/exoplayer/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoderException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 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.exoplayer2.text;
17 |
18 | /**
19 | * Thrown when an error occurs decoding subtitle data.
20 | */
21 | public class SubtitleDecoderException extends Exception {
22 |
23 | /**
24 | * @param message The detail message for this exception.
25 | */
26 | public SubtitleDecoderException(String message) {
27 | super(message);
28 | }
29 |
30 | /**
31 | * @param message The detail message for this exception.
32 | * @param cause The cause of this exception.
33 | */
34 | public SubtitleDecoderException(String message, Throwable cause) {
35 | super(message, cause);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/exoplayer/src/main/java/com/google/android/exoplayer2/text/SubtitleInputBuffer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 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.exoplayer2.text;
17 |
18 | import com.google.android.exoplayer2.Format;
19 | import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
20 |
21 | /** A {@link DecoderInputBuffer} for a {@link SubtitleDecoder}. */
22 | public class SubtitleInputBuffer extends DecoderInputBuffer {
23 |
24 | /**
25 | * An offset that must be added to the subtitle's event times after it's been decoded, or
26 | * {@link Format#OFFSET_SAMPLE_RELATIVE} if {@link #timeUs} should be added.
27 | */
28 | public long subsampleOffsetUs;
29 |
30 | public SubtitleInputBuffer() {
31 | super(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_NORMAL);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/exoplayer/src/main/java/com/google/android/exoplayer2/text/TextOutput.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 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.exoplayer2.text;
17 |
18 | import java.util.List;
19 |
20 | /**
21 | * Receives text output.
22 | */
23 | public interface TextOutput {
24 |
25 | /**
26 | * Called when there is a change in the {@link Cue}s.
27 | *
28 | * @param cues The {@link Cue}s.
29 | */
30 | void onCues(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 might not be at the start of the
28 | * array, and so {@link #offset} must be used when indexing into it.
29 | */
30 | public final byte[] data;
31 |
32 | /**
33 | * The offset of the allocated space in {@link #data}.
34 | */
35 | public final int offset;
36 |
37 | /**
38 | * @param data The array containing the allocated space.
39 | * @param offset The offset of the allocated space in {@code data}.
40 | */
41 | public Allocation(byte[] data, int offset) {
42 | this.data = data;
43 | this.offset = offset;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/exoplayer/src/main/java/com/google/android/exoplayer2/upstream/DataSourceException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 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.exoplayer2.upstream;
17 |
18 | import java.io.IOException;
19 |
20 | /**
21 | * Used to specify reason of a DataSource error.
22 | */
23 | public final class DataSourceException extends IOException {
24 |
25 | public static final int POSITION_OUT_OF_RANGE = 0;
26 |
27 | /**
28 | * The reason of this {@link DataSourceException}. It can only be {@link #POSITION_OUT_OF_RANGE}.
29 | */
30 | public final int reason;
31 |
32 | /**
33 | * Constructs a DataSourceException.
34 | *
35 | * @param reason Reason of the error. It can only be {@link #POSITION_OUT_OF_RANGE}.
36 | */
37 | public DataSourceException(int reason) {
38 | this.reason = reason;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/exoplayer/src/main/java/com/google/android/exoplayer2/upstream/FileDataSourceFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 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.exoplayer2.upstream;
17 |
18 | /**
19 | * A {@link DataSource.Factory} that produces {@link FileDataSource}.
20 | */
21 | public final class FileDataSourceFactory implements DataSource.Factory {
22 |
23 | private final TransferListener super FileDataSource> listener;
24 |
25 | public FileDataSourceFactory() {
26 | this(null);
27 | }
28 |
29 | public FileDataSourceFactory(TransferListener super FileDataSource> listener) {
30 | this.listener = listener;
31 | }
32 |
33 | @Override
34 | public DataSource createDataSource() {
35 | return new FileDataSource(listener);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/exoplayer/src/main/java/com/google/android/exoplayer2/upstream/TransferListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 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.exoplayer2.upstream;
17 |
18 | /**
19 | * A listener of data transfer events.
20 | */
21 | public interface TransferListener {
22 |
23 | /**
24 | * Called when a transfer starts.
25 | *
26 | * @param source The source performing the transfer.
27 | * @param dataSpec Describes the data being transferred.
28 | */
29 | void onTransferStart(S source, DataSpec dataSpec);
30 |
31 | /**
32 | * Called incrementally during a transfer.
33 | *
34 | * @param source The source performing the transfer.
35 | * @param bytesTransferred The number of bytes transferred since the previous call to this
36 | * method (or if the first call, since the transfer was started).
37 | */
38 | void onBytesTransferred(S source, int bytesTransferred);
39 |
40 | /**
41 | * Called when a transfer ends.
42 | *
43 | * @param source The source performing the transfer.
44 | */
45 | void onTransferEnd(S source);
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/exoplayer/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheEvictor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 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.exoplayer2.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 | * Called when cache has been initialized.
26 | */
27 | void onCacheInitialized();
28 |
29 | /**
30 | * Called when a writer starts writing to the cache.
31 | *
32 | * @param cache The source of the event.
33 | * @param key The key being written.
34 | * @param position The starting position of the data being written.
35 | * @param maxLength The maximum length of the data being written.
36 | */
37 | void onStartFile(Cache cache, String key, long position, long maxLength);
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/exoplayer/src/main/java/com/google/android/exoplayer2/upstream/cache/NoOpCacheEvictor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 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.exoplayer2.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 onCacheInitialized() {
29 | // Do nothing.
30 | }
31 |
32 | @Override
33 | public void onStartFile(Cache cache, String key, long position, long maxLength) {
34 | // Do nothing.
35 | }
36 |
37 | @Override
38 | public void onSpanAdded(Cache cache, CacheSpan span) {
39 | // Do nothing.
40 | }
41 |
42 | @Override
43 | public void onSpanRemoved(Cache cache, CacheSpan span) {
44 | // Do nothing.
45 | }
46 |
47 | @Override
48 | public void onSpanTouched(Cache cache, CacheSpan oldSpan, CacheSpan newSpan) {
49 | // Do nothing.
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/exoplayer/src/main/java/com/google/android/exoplayer2/upstream/crypto/CryptoUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2016 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.exoplayer2.upstream.crypto;
17 |
18 | /**
19 | * Utility functions for the crypto package.
20 | */
21 | /* package */ final class CryptoUtil {
22 |
23 | private CryptoUtil() {}
24 |
25 | /**
26 | * Returns the hash value of the input as a long using the 64 bit FNV-1a hash function. The hash
27 | * values produced by this function are less likely to collide than those produced by
28 | * {@link #hashCode()}.
29 | */
30 | public static long getFNV64Hash(String input) {
31 | if (input == null) {
32 | return 0;
33 | }
34 |
35 | long hash = 0;
36 | for (int i = 0; i < input.length(); i++) {
37 | hash ^= input.charAt(i);
38 | // This is equivalent to hash *= 0x100000001b3 (the FNV magic prime number).
39 | hash += (hash << 1) + (hash << 4) + (hash << 5) + (hash << 7) + (hash << 8) + (hash << 40);
40 | }
41 | return hash;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/exoplayer/src/main/java/com/google/android/exoplayer2/util/ErrorMessageProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 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.exoplayer2.util;
17 |
18 | import android.util.Pair;
19 |
20 | /** Converts throwables into error codes and user readable error messages. */
21 | public interface ErrorMessageProvider