AliyunPlayer  v5.2.0
Aliyun Player API Reference Manual for Windows Platforms
AliMediaDownloader.h
1 //
2 // AliMediaDownloader.h
3 //
4 // Created by kongjian.kongjian on 2020/06/04.
5 //
6 
7 #ifndef AliMediaDownloader_h
8 #define AliMediaDownloader_h
9 
10 #include "AVPDef.h"
11 #include "AVPMediaInfo.h"
12 #include "AVPSource.h"
13 #include "AVDConfig.h"
14 
15 namespace alivc_player {
16 
17  class AliMediaDownloader;
18 
19  class IAVDListener {
20  public:
26  virtual void onPrepared(AliMediaDownloader *downloader, AVPMediaInfo *mediaInfo) = 0;
27 
28  /****
29  @brief error callback.
30  @param downloader Downloader pointer.
31  @param errorModel Player error description. See AliVcPlayerErrorModel
32  */
33  virtual void onError(AliMediaDownloader *downloader, AVPErrorModel *errorModel) = 0;
34 
35  /****
36  @brief Download progress callback.
37  @param downloader Downloader pointer.
38  @param percent Download progress: 0 to 100.
39  */
40  virtual void onDownloadingProgress(AliMediaDownloader *downloader, int percent) = 0;
41 
42  /****
43  @brief Downloaded file processing progress callback.
44  @param downloader Downloader pointer.
45  @param percent Processing progress: 0 to 100.
46  */
47  virtual void onProcessingProgress(AliMediaDownloader *downloader, int percent) = 0;
48 
49  /****
50  @brief Download completion callback.
51  @param downloader Downloader pointer.
52  */
53  virtual void onCompletion(AliMediaDownloader *downloader) = 0;
54  };
55 
56  class ALIVC_EXTERN AliMediaDownloader {
57  public:
58  static AliMediaDownloader *CreateMediaDownloader();
59 
60  virtual ~AliMediaDownloader() = default;
61 
62  /****
63  @brief Delete a downloaded file.
64  @param saveDir The path where the file is saved.
65  @param vid VID.
66  @param format Format.
67  @param index The download index corresponds to the VID.
68  */
69  static int deleteFile(const char *saveDir, const char *vid, const char *format, int index);
70 
71  /****
72  @brief Use AVPVidStsSource to prepare for download.
73  @param source vid STS information.
74  */
75  virtual void prepareWithVid(AVPVidStsSource *source) = 0;
76 
77  /****
78  @brief Update the AVPVidStsSource information when the authentication expires.
79  @param source vid STS information.
80  */
81  virtual void updateWithVid(AVPVidStsSource *source) = 0;
82 
83  /****
84  @brief Use AVPVidAuthSource to prepare for download.
85  @param source vid Authentication information.
86  */
87  virtual void prepareWithPlayAuth(AVPVidAuthSource *source) = 0;
88 
89  /****
90  @brief Update the AVPVidAuthSource information when the authentication expires.
91  @param source vid Authentication information.
92  */
93  virtual void updateWithPlayAuth(AVPVidAuthSource *source) = 0;
94 
95  /****
96  @brief Set a path to save the downloaded file.
97  @param dir The specified path.
98  */
99  virtual void setSaveDirectory(const char *dir) = 0;
100 
101  /****
102  @brief Start downloading.
103  */
104  virtual void start() = 0;
105 
106  /****
107  @brief Pause downloading.
108  */
109  virtual void stop() = 0;
110 
111  /****
112  @brief Delete the downloaded file.
113  */
114  virtual void deleteDownloadedFile() = 0;
115 
116  /****
117  @brief Query download config. do not free the return value
118  */
119  virtual AVDConfig *getConfig() = 0;
120 
121  /****
122  @brief Modify download config.
123  */
124  virtual void setConfig(AVDConfig *config) = 0;
125 
126  /****
127  @brief Specify the indexes of the tracks to be downloaded.
128  @param trackIndex Use the prepare callback to retrieve all track indexes.
129  */
130  virtual void selectTrack(int trackIndex) = 0;
131 
132  /****
133  @brief Set a URL conversion callback. URL conversion is typically used in P2P broadcasting.
134  @param callback The function pointer of the callback.
135  */
136  virtual void setPlayUrlConvertCallback(PlayURLConvertCallback callback) = 0;
137 
141  virtual void setListener(IAVDListener *listener) = 0;
142 
146  virtual IAVDListener* getListener() = 0;
147 
148  /****
149  @brief Query the path of the downloaded file. do not need to free
150  */
151  virtual const char *getDownloadedFilePath() = 0;
152  };
153 
154 };// namespace alivc_player
155 
156 #endif /* AliMediaDownloader_h */
alivc_player::IAVDListener
Definition: AliMediaDownloader.h:19
alivc_player::AliMediaDownloader::getListener
virtual IAVDListener * getListener()=0
get callback listener
alivc_player::_AVPErrorModel
Definition: AVPDef.h:135
alivc_player::AVPVidAuthSource
Definition: AVPSource.h:130
alivc_player::AliMediaDownloader
Definition: AliMediaDownloader.h:56
alivc_player::IAVDListener::onPrepared
virtual void onPrepared(AliMediaDownloader *downloader, AVPMediaInfo *mediaInfo)=0
Download preparation completion callback.
alivc_player::_AVDConfig
Definition: AVDConfig.h:15
alivc_player::AliMediaDownloader::setListener
virtual void setListener(IAVDListener *listener)=0
set callback listener
alivc_player::AVPVidStsSource
Definition: AVPSource.h:73