M3U8 Specification

本文档详细介绍了HTTP直播流协议,该协议用于传输无界限的多媒体数据流,规定了文件的数据格式及服务器与客户端的操作流程,并描述了协议的第4版。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 http://tools.ietf.org/html/draft-pantos-http-live-streaming-07

HTTP Live Streaming draft-pantos-http-live-streaming-07

Abstract This document describes a protocol for transferring unbounded streams of multimedia data. It specifies the data format of the files and the actions to be taken by the server (sender) and the clients (receivers) of the streams. It describes version 4 of this protocol.

 

Table of Contents

   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  4
   2.  Summary  . . . . . . . . . . . . . . . . . . . . . . . . . . .  4
   3.  The Playlist file  . . . . . . . . . . . . . . . . . . . . . .  4
     3.1.  Introduction . . . . . . . . . . . . . . . . . . . . . . .  4
     3.2.  Attribute Lists  . . . . . . . . . . . . . . . . . . . . .  6
     3.3.  New Tags . . . . . . . . . . . . . . . . . . . . . . . . .  7
       3.3.1.  EXT-X-BYTERANGE  . . . . . . . . . . . . . . . . . . .  7
       3.3.2.  EXT-X-TARGETDURATION . . . . . . . . . . . . . . . . .  7
       3.3.3.  EXT-X-MEDIA-SEQUENCE . . . . . . . . . . . . . . . . .  8
       3.3.4.  EXT-X-KEY  . . . . . . . . . . . . . . . . . . . . . .  8
       3.3.5.  EXT-X-PROGRAM-DATE-TIME  . . . . . . . . . . . . . . .  9
       3.3.6.  EXT-X-ALLOW-CACHE  . . . . . . . . . . . . . . . . . .  9
       3.3.7.  EXT-X-PLAYLIST-TYPE  . . . . . . . . . . . . . . . . .  9
       3.3.8.  EXT-X-ENDLIST  . . . . . . . . . . . . . . . . . . . . 10
       3.3.9.  EXT-X-MEDIA  . . . . . . . . . . . . . . . . . . . . . 10
         3.3.9.1.  Rendition Groups . . . . . . . . . . . . . . . . . 11
       3.3.10. EXT-X-STREAM-INF . . . . . . . . . . . . . . . . . . . 12
         3.3.10.1. Alternative Renditions . . . . . . . . . . . . . . 13
       3.3.11. EXT-X-DISCONTINUITY  . . . . . . . . . . . . . . . . . 14
       3.3.12. EXT-X-I-FRAMES-ONLY  . . . . . . . . . . . . . . . . . 14
       3.3.13. EXT-X-I-FRAME-STREAM-INF . . . . . . . . . . . . . . . 15
       3.3.14. EXT-X-VERSION  . . . . . . . . . . . . . . . . . . . . 15
   4.  Media segments . . . . . . . . . . . . . . . . . . . . . . . . 16
   5.  Key files  . . . . . . . . . . . . . . . . . . . . . . . . . . 17
     5.1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . 17
     5.2.  IV for AES-128 . . . . . . . . . . . . . . . . . . . . . . 17
   6.  Client/Server Actions  . . . . . . . . . . . . . . . . . . . . 17
     6.1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . 17
     6.2.  Server Process . . . . . . . . . . . . . . . . . . . . . . 17
       6.2.1.  Introduction . . . . . . . . . . . . . . . . . . . . . 17
       6.2.2.  Sliding Window Playlists . . . . . . . . . . . . . . . 19
       6.2.3.  Encrypting media segments  . . . . . . . . . . . . . . 20
       6.2.4.  Providing variant streams  . . . . . . . . . . . . . . 21
     6.3.  Client Process . . . . . . . . . . . . . . . . . . . . . . 22
       6.3.1.  Introduction . . . . . . . . . . . . . . . . . . . . . 22
       6.3.2.  Loading the Playlist file  . . . . . . . . . . . . . . 22
       6.3.3.  Playing the Playlist file  . . . . . . . . . . . . . . 22
       6.3.4.  Reloading the Playlist file  . . . . . . . . . . . . . 23
       6.3.5.  Determining the next segment to load . . . . . . . . . 24
       6.3.6.  Decrypting encrypted media segments  . . . . . . . . . 24



Pantos & May              Expires April 2, 2012                 [Page 2]
 
Internet-Draft             HTTP Live Streaming            September 2011


   7.  Protocol version compatibility . . . . . . . . . . . . . . . . 25
   8.  Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
     8.1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . 25
     8.2.  Simple Playlist file . . . . . . . . . . . . . . . . . . . 26
     8.3.  Sliding Window Playlist, using HTTPS . . . . . . . . . . . 26
     8.4.  Playlist file with encrypted media segments  . . . . . . . 26
     8.5.  Variant Playlist file  . . . . . . . . . . . . . . . . . . 27
     8.6.  Variant Playlist with I-Frames . . . . . . . . . . . . . . 27
     8.7.  Variant Playlist with Alternative audio  . . . . . . . . . 27
     8.8.  Variant Playlist with Alternative video  . . . . . . . . . 28
   9.  Contributors . . . . . . . . . . . . . . . . . . . . . . . . . 29
   10. IANA Considerations  . . . . . . . . . . . . . . . . . . . . . 29
   11. Security Considerations  . . . . . . . . . . . . . . . . . . . 30
   12. References . . . . . . . . . . . . . . . . . . . . . . . . . . 31
     12.1. Normative References . . . . . . . . . . . . . . . . . . . 31
     12.2. Informative References . . . . . . . . . . . . . . . . . . 32
   Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 32

 

 


                
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #define PY_SSIZE_T_CLEAN #include "eiger_defs.h" #include "raw_file.h" #include <Python.h> #include <numpy/arrayobject.h> #include <stdio.h> #include <unistd.h> // #define VERBOSE /* Docstrings */ static char module_docstring[] = "sls_cmodule provies access to compiled c++ and ROOT functions supporting " "detector calibration. The library uses numpy arrays as input and return " "values."; /* Available functions */ static PyObject *read_raw(PyObject *self, PyObject *args); static PyObject *mt_read(PyObject *self, PyObject *args); static PyObject *read_m3(PyObject *self, PyObject *args, PyObject *kwargs); static PyArray_Descr *get_frame_header_dt(); /* Module specification */ static PyMethodDef module_methods[] = { {"read_frame", (PyCFunction)read_raw, METH_VARARGS, "hej"}, {"mt_read", (PyCFunction)mt_read, METH_VARARGS, "hej"}, {"read_m3", (PyCFunction)read_m3, METH_VARARGS | METH_KEYWORDS, "hej"}, {NULL, NULL, 0, NULL}}; static struct PyModuleDef hdf5maker_def = { PyModuleDef_HEAD_INIT, "_hdf5maker", module_docstring, -1, module_methods}; /* Initialize the module */ PyMODINIT_FUNC PyInit__hdf5maker(void) { PyObject *m = PyModule_Create(&hdf5maker_def); if (m == NULL) { return NULL; } /* Load `numpy` functionality. */ import_array(); PyArray_Descr *obj = get_frame_header_dt(); PyObject_SetAttrString(m, "frame_header_dt", (PyObject *)obj); Py_DECREF(obj); return m; } static PyObject *mt_read(PyObject *self, PyObject *args) { return NULL; } static PyObject *read_raw(PyObject *self, PyObject *args) { //Passing in: // file, dr, n_frames PyObject *fobj; int n_frames, dr; if (!PyArg_ParseTuple(args, "OII", &fobj, &dr, &n_frames)) return NULL; int fd = PyObject_AsFileDescriptor(fobj); if (fd < 0) return NULL; // Allocate data for header and frames PyArray_Descr *dtype = get_frame_header_dt(); const npy_intp header_dims[] = {n_frames}; PyObject *header = PyArray_SimpleNewFromDescr(1, header_dims, dtype); npy_intp dims[] = {n_frames, PORT_NROWS_WGAP, PORT_NCOLS_WGAP}; PyObject *data = PyArray_SimpleNew(3, dims, dr_to_dtype(dr)); const size_t bytes_to_copy = dr * PORT_NROWS * PORT_NCOLS / 8; sls_detector_header *h_ptr = (sls_detector_header *)PyArray_BYTES((PyArrayObject *)header); uint8_t *frame_ptr = (uint8_t *)PyArray_BYTES((PyArrayObject *)data); PyArray_FILLWBYTE((PyArrayObject *)data, 0); const int stride = PyArray_STRIDE((PyArrayObject *)data, 0); uint8_t *buffer = malloc(bytes_to_copy + sizeof(sls_detector_header)); uint8_t *expanded_buffer = NULL; if (dr == 4) { expanded_buffer = malloc(bytes_to_copy * 2); } for (int i = 0; i < n_frames; ++i) { read(fd, buffer, bytes_to_copy + sizeof(sls_detector_header)); memcpy(h_ptr, buffer, sizeof(sls_detector_header)); if (dr == 4) { uint8_t *dst = expanded_buffer; uint8_t *src = buffer + sizeof(sls_detector_header); for (size_t j = 0; j < bytes_to_copy; ++j) { *dst++ = *src & 0xfu; *dst++ = *src++ >> 4u; } copy_to_place(frame_ptr, expanded_buffer, 8, h_ptr->row, h_ptr->column); } else { copy_to_place(frame_ptr, buffer + sizeof(sls_detector_header), dr, h_ptr->row, h_ptr->column); } frame_ptr += stride; h_ptr++; } free(buffer); free(expanded_buffer); PyObject *ret = PyTuple_Pack(2, header, data); Py_DECREF(header); Py_DECREF(data); return ret; } static PyObject *read_m3(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject *fobj; static char *keywords[] = {"fd","dr","n_frames", "n_chan", NULL}; int n_frames, dr, n_chan; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OIII", keywords, &fobj, &dr, &n_frames, &n_chan)) { return NULL; } // if (!PyArg_ParseTuple(args, "OIII", &fobj, &dr, &n_frames, &n_chan)) // return NULL; int fd = PyObject_AsFileDescriptor(fobj); if (fd < 0) return NULL; // Allocate data for header and frames PyArray_Descr *dtype = get_frame_header_dt(); const npy_intp header_dims[] = {n_frames}; PyObject *header = PyArray_SimpleNewFromDescr(1, header_dims, dtype); npy_intp dims[] = {n_frames, n_chan}; PyObject *data = PyArray_SimpleNew(2, dims, dr_to_dtype(dr)); const size_t bytes_to_copy = dr * n_chan / 8; sls_detector_header *h_ptr = (sls_detector_header *)PyArray_BYTES((PyArrayObject *)header); uint8_t *frame_ptr = (uint8_t *)PyArray_BYTES((PyArrayObject *)data); PyArray_FILLWBYTE((PyArrayObject *)data, 0); const int stride = PyArray_STRIDE((PyArrayObject *)data, 0); uint8_t *buffer = malloc(bytes_to_copy + sizeof(sls_detector_header)); uint8_t *expanded_buffer = NULL; if (dr == 4) { expanded_buffer = malloc(bytes_to_copy * 2); } for (int i = 0; i < n_frames; ++i) { read(fd, buffer, bytes_to_copy + sizeof(sls_detector_header)); memcpy(h_ptr, buffer, sizeof(sls_detector_header)); memcpy(frame_ptr, buffer + sizeof(sls_detector_header), bytes_to_copy); frame_ptr += stride; h_ptr++; } free(buffer); free(expanded_buffer); PyObject *ret = PyTuple_Pack(2, header, data); Py_DECREF(header); Py_DECREF(data); return ret; } static PyArray_Descr *get_frame_header_dt() { // Move this to a function that gets run on init PyObject *dtype_dict; PyArray_Descr *dtype; dtype_dict = Py_BuildValue( "[(s, s), (s, s), (s, s), (s, s), (s, s), (s, s), (s, s), (s, s), (s, " "s), (s, s), (s, s), (s, s), (s, s), (s, s)]", "Frame Number", "u8", "SubFrame Number/ExpLength", "u4", "Packet Number", "u4", "Bunch ID", "u8", "Timestamp", "u8", "Module Id", "u2", "Row", "u2", "Column", "u2", "Reserved", "u2", "Debug", "u4", "Round Robin Number", "u2", "Detector Type", "u1", "Header Version", "u1", "Packets Caught Mask", "V64"); PyArray_DescrConverter(dtype_dict, &dtype); Py_DECREF(dtype_dict); return dtype; }
08-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值