1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 package org.mozilla.gecko.media;
6 
7 import java.util.concurrent.ConcurrentLinkedQueue;
8 
9 public interface BaseHlsPlayer {
10 
11     public enum TrackType {
12         UNDEFINED,
13         AUDIO,
14         VIDEO,
15         TEXT,
16     }
17 
18     public enum ResourceError {
19         BASE(-100),
20         UNKNOWN(-101),
21         PLAYER(-102),
22         UNSUPPORTED(-103);
23 
24         private int mNumVal;
ResourceError(final int numVal)25         private ResourceError(final int numVal) {
26             mNumVal = numVal;
27         }
code()28         public int code() {
29             return mNumVal;
30         }
31     }
32 
33     public enum DemuxerError {
34         BASE(-200),
35         UNKNOWN(-201),
36         PLAYER(-202),
37         UNSUPPORTED(-203);
38 
39         private int mNumVal;
DemuxerError(final int numVal)40         private DemuxerError(final int numVal) {
41             mNumVal = numVal;
42         }
code()43         public int code() {
44             return mNumVal;
45         }
46     }
47 
48     public interface DemuxerCallbacks {
onInitialized(boolean hasAudio, boolean hasVideo)49         void onInitialized(boolean hasAudio, boolean hasVideo);
onError(int errorCode)50         void onError(int errorCode);
51     }
52 
53     public interface ResourceCallbacks {
onLoad(String mediaUrl)54         void onLoad(String mediaUrl);
onDataArrived()55         void onDataArrived();
onError(int errorCode)56         void onError(int errorCode);
57     }
58 
59     // Used to identify player instance.
getId()60     public int getId();
61 
62     // =======================================================================
63     // API for GeckoHLSResourceWrapper
64     // =======================================================================
init(String url, ResourceCallbacks callback)65     public void init(String url, ResourceCallbacks callback);
66 
isLiveStream()67     public boolean isLiveStream();
68 
69     // =======================================================================
70     // API for GeckoHLSDemuxerWrapper
71     // =======================================================================
addDemuxerWrapperCallbackListener(DemuxerCallbacks callback)72     public void addDemuxerWrapperCallbackListener(DemuxerCallbacks callback);
73 
getSamples(TrackType trackType, int number)74     public ConcurrentLinkedQueue<GeckoHLSSample> getSamples(TrackType trackType, int number);
75 
getBufferedPosition()76     public long getBufferedPosition();
77 
getNumberOfTracks(TrackType trackType)78     public int getNumberOfTracks(TrackType trackType);
79 
getVideoInfo(int index)80     public GeckoVideoInfo getVideoInfo(int index);
81 
getAudioInfo(int index)82     public GeckoAudioInfo getAudioInfo(int index);
83 
seek(long positionUs)84     public boolean seek(long positionUs);
85 
getNextKeyFrameTime()86     public long getNextKeyFrameTime();
87 
suspend()88     public void suspend();
89 
resume()90     public void resume();
91 
play()92     public void play();
93 
pause()94     public void pause();
95 
release()96     public void release();
97 }
98