![]() |
MHEG5
22.11.0
|
IC Streamer download manager. More...
#include <assert.h>
#include <string.h>
#include "stb_os.h"
#include "glue_memory.h"
#include "glue_debug.h"
#include "glue_queue.h"
#include "http_interface.h"
#include "stmr_dl.h"
#include "stmr_common.h"
#include "http_header.h"
#include "stmr_header.h"
#include "stmr_queue.h"
#include "mh5streamer.h"
Classes | |
struct | sPsiInfo |
struct | sDownloadRequest |
Macros | |
#define | INVALID_TIMESTAMP 0xffffffff |
#define | SYNC_BYTE 0x47 |
#define | SYNC_COUNT_ACCEPT 20 |
#define | SYNC_BUFFER_SIZE (STMR_TS_PACKET_SIZE * SYNC_COUNT_ACCEPT) |
#define | SYNC_COUNT_MIN_ACCEPT (SYNC_COUNT_ACCEPT / 2) |
#define | USE_MAGIC |
#define | GOOD_MAGIC 0xdeadbeef |
#define | BAD_MAGIC 0xfefefefe |
#define | SET_MAGIC(r) do { r->magic = GOOD_MAGIC; } while (0) |
#define | VERIFY_MAGIC(r) assert(r->magic == GOOD_MAGIC) |
#define | CLEAR_MAGIC(r) do { r->magic = BAD_MAGIC; } while (0) |
#define | DBG(x) |
#define | PDBG(x) TRACE(TICS, x) |
Typedefs | |
typedef struct sPsiInfo | PsiInfo |
typedef struct sDownloadRequest | DownloadRequest |
Enumerations | |
enum | SyncState { SYNC_ACCUM, SYNC_FOUND, SYNC_FAILED } |
enum | PsiState { PSI_STATE_PAT, PSI_STATE_PMT, PSI_STATE_PCR } |
Functions | |
U32BIT | MHEG5CreateDownloadRequest (U32BIT requestId, char *url, U64HL rangeFrom, U64HL rangeTo, BOOLEAN lastRequest) |
Create HTTP download request. More... | |
void | MHEG5StartDownloadRequest (U32BIT downloadId) |
Start HTTP download request. More... | |
U8BIT * | MHEG5GetDownloadRedirect (U32BIT downloadId) |
Return the redirection URL for a request that was redirected (HTTP status 3xx). More... | |
BOOLEAN | MHEG5DownloadPositionPartial (U32BIT downloadId, U64HL *position) |
Return what is current position of download request. More... | |
U64HL | MHEG5GetDownloadContentLength (U32BIT downloadId, U64HL contentLength) |
Return content length (in bytes) for download request. The content length may be: More... | |
void | MHEG5CopyDownloadBitrate (U32BIT downloadId, U32BIT *bytesPerSecond) |
Copy download bitrate that was obtained from the headers. If the X-BytesPerSecond header were not received, the bitrate is not updated. More... | |
void | MHEG5CopyDownloadStreamKeyInfo (U32BIT downloadId, S_ICSKeys *keys, MHEG5String *keyLocation) |
Copy any keys or key location that were obtained from the headers. If such keys or location exist, they are also cleared from the download request (i.e. ownership is transferred to the caller). In addition, the caller keys and key location are also cleared. If such keys or key location does not exist, the function does not overwrite the caller's keys or key location. More... | |
BOOLEAN | MHEG5GetDownloadPmt (U32BIT downloadId, U8BIT *pmt) |
Return program map table (PMT) for download (if available). The table is provided as a complete section, including table_id and CRC_32. More... | |
void | MHEG5ResumeDownload (void) |
Resume download of the active request. Download may or may not have been paused due to the buffer being full. More... | |
void | MHEG5ClearDownloadThrottling (void) |
Clear information about throttling, causing the download to proceed at full speed (until throttling kicks in again). More... | |
void | MHEG5StopDownloadRequest (U32BIT downloadId) |
Stop HTTP download request. More... | |
void | MHEG5StopDownloadRequestAsync (U32BIT downloadId) |
Stop HTTP download request asynchronously. This function should be used when the caller wants to stop the download from one of the callbacks. In that case the download will be paused and notified as complete. The caller can then handle the event and stop/destroy the request. More... | |
void | MHEG5DestroyDownloadRequest (U32BIT downloadId) |
Destroy HTTP download request. More... | |
void | MHEG5ClearDownloadRequest (U32BIT downloadId) |
Clear HTTP download request. More... | |
void | MHEG5RenewDownloadRequest (U32BIT downloadId, char *url) |
Renew HTTP download request. More... | |
IC Streamer download manager.
void MHEG5ClearDownloadRequest | ( | U32BIT | downloadId | ) |
Clear HTTP download request.
downloadId | Download request ID |
void MHEG5ClearDownloadThrottling | ( | void | ) |
Clear information about throttling, causing the download to proceed at full speed (until throttling kicks in again).
void MHEG5CopyDownloadBitrate | ( | U32BIT | downloadId, |
U32BIT * | bytesPerSecond | ||
) |
Copy download bitrate that was obtained from the headers. If the X-BytesPerSecond header were not received, the bitrate is not updated.
downloadId | Download request ID |
bytesPerSecond | Stream bitrate (bytes per second) |
void MHEG5CopyDownloadStreamKeyInfo | ( | U32BIT | downloadId, |
S_ICSKeys * | keys, | ||
MHEG5String * | keyLocation | ||
) |
Copy any keys or key location that were obtained from the headers. If such keys or location exist, they are also cleared from the download request (i.e. ownership is transferred to the caller). In addition, the caller keys and key location are also cleared. If such keys or key location does not exist, the function does not overwrite the caller's keys or key location.
downloadId | Download request ID |
keys | Keys (if any) |
keyLocation | Key location (if any) |
U32BIT MHEG5CreateDownloadRequest | ( | U32BIT | requestId, |
char * | url, | ||
U64HL | rangeFrom, | ||
U64HL | rangeTo, | ||
BOOLEAN | lastRequest | ||
) |
Create HTTP download request.
requestId | Request ID to be stored with downloaded items |
url | URL for request |
rangeFrom | Range from in bytes (0 for "start") |
rangeTo | Range to in bytes (invalid for "end") |
lastRequest | Whether this is the last request for this URL |
void MHEG5DestroyDownloadRequest | ( | U32BIT | downloadId | ) |
Destroy HTTP download request.
downloadId | Download request ID |
BOOLEAN MHEG5DownloadPositionPartial | ( | U32BIT | downloadId, |
U64HL * | position | ||
) |
Return what is current position of download request.
downloadId | Download request ID |
position | current position (downloaded bytes) |
U64HL MHEG5GetDownloadContentLength | ( | U32BIT | downloadId, |
U64HL | contentLength | ||
) |
Return content length (in bytes) for download request. The content length may be:
downloadId | Download request ID |
contentLength | Content length in bytes |
BOOLEAN MHEG5GetDownloadPmt | ( | U32BIT | downloadId, |
U8BIT * | pmt | ||
) |
Return program map table (PMT) for download (if available). The table is provided as a complete section, including table_id and CRC_32.
downloadId | Download request ID |
pmt | Storage area for PMT (1024 bytes) |
U8BIT* MHEG5GetDownloadRedirect | ( | U32BIT | downloadId | ) |
Return the redirection URL for a request that was redirected (HTTP status 3xx).
downloadId | Download request ID |
void MHEG5RenewDownloadRequest | ( | U32BIT | downloadId, |
char * | url | ||
) |
Renew HTTP download request.
downloadId | Download request ID |
void MHEG5ResumeDownload | ( | void | ) |
Resume download of the active request. Download may or may not have been paused due to the buffer being full.
void MHEG5StartDownloadRequest | ( | U32BIT | downloadId | ) |
Start HTTP download request.
downloadId | Download request ID |
void MHEG5StopDownloadRequest | ( | U32BIT | downloadId | ) |
Stop HTTP download request.
downloadId | Download request ID |
void MHEG5StopDownloadRequestAsync | ( | U32BIT | downloadId | ) |
Stop HTTP download request asynchronously. This function should be used when the caller wants to stop the download from one of the callbacks. In that case the download will be paused and notified as complete. The caller can then handle the event and stop/destroy the request.
downloadId | Download request ID |