nestegg.h (25918B)
1 /* 2 * Copyright © 2010 Mozilla Foundation 3 * 4 * This program is made available under an ISC-style license. See the 5 * accompanying file LICENSE for details. 6 */ 7 #if !defined(NESTEGG_671cac2a_365d_ed69_d7a3_4491d3538d79) 8 #define NESTEGG_671cac2a_365d_ed69_d7a3_4491d3538d79 9 10 #include <limits.h> 11 #include <stdint.h> 12 13 #if defined(__cplusplus) 14 extern "C" { 15 #endif 16 17 /** @mainpage 18 19 @section intro Introduction 20 21 This is the documentation for the <tt>libnestegg</tt> C API. 22 <tt>libnestegg</tt> is a demultiplexing library for <a 23 href="http://www.webmproject.org/code/specs/container/">WebM</a> 24 media files. 25 26 @section example Example code 27 28 @code 29 nestegg * demux_ctx; 30 nestegg_init(&demux_ctx, io, NULL, -1); 31 32 nestegg_packet * pkt; 33 while ((r = nestegg_read_packet(demux_ctx, &pkt)) > 0) { 34 unsigned int track; 35 36 nestegg_packet_track(pkt, &track); 37 38 // This example decodes the first track only. 39 if (track == 0) { 40 unsigned int chunk, chunks; 41 42 nestegg_packet_count(pkt, &chunks); 43 44 // Decode each chunk of data. 45 for (chunk = 0; chunk < chunks; ++chunk) { 46 unsigned char * data; 47 size_t data_size; 48 49 nestegg_packet_data(pkt, chunk, &data, &data_size); 50 51 example_codec_decode(codec_ctx, data, data_size); 52 } 53 } 54 55 nestegg_free_packet(pkt); 56 } 57 58 nestegg_destroy(demux_ctx); 59 @endcode 60 */ 61 62 63 /** @file 64 The <tt>libnestegg</tt> C API. */ 65 66 #define NESTEGG_TRACK_VIDEO 0 /**< Track is of type video. */ 67 #define NESTEGG_TRACK_AUDIO 1 /**< Track is of type audio. */ 68 #define NESTEGG_TRACK_UNKNOWN INT_MAX /**< Track is of type unknown. */ 69 70 #define NESTEGG_CODEC_VP8 0 /**< Track uses Google On2 VP8 codec. */ 71 #define NESTEGG_CODEC_VORBIS 1 /**< Track uses Xiph Vorbis codec. */ 72 #define NESTEGG_CODEC_VP9 2 /**< Track uses Google On2 VP9 codec. */ 73 #define NESTEGG_CODEC_OPUS 3 /**< Track uses Xiph Opus codec. */ 74 #define NESTEGG_CODEC_AV1 4 /**< Track uses AOMedia AV1 codec. */ 75 #define NESTEGG_CODEC_AVC 5 /**< Track uses H.264/AVC codec. */ 76 #define NESTEGG_CODEC_HEVC 6 /**< Track uses H.265/HEVC codec. */ 77 #define NESTEGG_CODEC_AAC 7 /**< Track uses AAC codec. */ 78 #define NESTEGG_CODEC_FLAC 8 /**< Track uses FLAC codec. */ 79 #define NESTEGG_CODEC_MP3 9 /**< Track uses MP3 codec */ 80 #define NESTEGG_CODEC_PCM 10 /**< Track uses PCM codec. */ 81 #define NESTEGG_CODEC_UNKNOWN INT_MAX /**< Track uses unknown codec. */ 82 83 #define NESTEGG_VIDEO_MONO 0 /**< Track is mono video. */ 84 #define NESTEGG_VIDEO_STEREO_LEFT_RIGHT 1 /**< Track is side-by-side stereo video. Left first. */ 85 #define NESTEGG_VIDEO_STEREO_BOTTOM_TOP 2 /**< Track is top-bottom stereo video. Right first. */ 86 #define NESTEGG_VIDEO_STEREO_TOP_BOTTOM 3 /**< Track is top-bottom stereo video. Left first. */ 87 #define NESTEGG_VIDEO_STEREO_RIGHT_LEFT 11 /**< Track is side-by-side stereo video. Right first. */ 88 89 #define NESTEGG_SEEK_SET 0 /**< Seek offset relative to beginning of stream. */ 90 #define NESTEGG_SEEK_CUR 1 /**< Seek offset relative to current position in stream. */ 91 #define NESTEGG_SEEK_END 2 /**< Seek offset relative to end of stream. */ 92 93 #define NESTEGG_LOG_DEBUG 1 /**< Debug level log message. */ 94 #define NESTEGG_LOG_INFO 10 /**< Informational level log message. */ 95 #define NESTEGG_LOG_WARNING 100 /**< Warning level log message. */ 96 #define NESTEGG_LOG_ERROR 1000 /**< Error level log message. */ 97 #define NESTEGG_LOG_CRITICAL 10000 /**< Critical level log message. */ 98 99 #define NESTEGG_ENCODING_COMPRESSION 0 /**< Content encoding type is compression. */ 100 #define NESTEGG_ENCODING_ENCRYPTION 1 /**< Content encoding type is encryption. */ 101 102 #define NESTEGG_PACKET_HAS_SIGNAL_BYTE_FALSE 0 /**< Packet does not have signal byte */ 103 #define NESTEGG_PACKET_HAS_SIGNAL_BYTE_UNENCRYPTED 1 /**< Packet has signal byte and is unencrypted */ 104 #define NESTEGG_PACKET_HAS_SIGNAL_BYTE_ENCRYPTED 2 /**< Packet has signal byte and is encrypted */ 105 #define NESTEGG_PACKET_HAS_SIGNAL_BYTE_PARTITIONED 4 /**< Packet has signal byte and is partitioned */ 106 107 #define NESTEGG_PACKET_HAS_KEYFRAME_FALSE 0 /**< Packet contains only keyframes. */ 108 #define NESTEGG_PACKET_HAS_KEYFRAME_TRUE 1 /**< Packet does not contain any keyframes */ 109 #define NESTEGG_PACKET_HAS_KEYFRAME_UNKNOWN 2 /**< Packet may or may not contain keyframes */ 110 111 typedef struct nestegg nestegg; /**< Opaque handle referencing the stream state. */ 112 typedef struct nestegg_packet nestegg_packet; /**< Opaque handle referencing a packet of data. */ 113 114 /** User supplied IO context. */ 115 typedef struct { 116 /** User supplied read callback. 117 @param buffer Buffer to read data into. 118 @param length Length of supplied buffer in bytes. 119 @param userdata The #userdata supplied by the user. 120 @retval 1 Read succeeded. 121 @retval 0 End of stream. 122 @retval -1 Error. */ 123 int (* read)(void * buffer, size_t length, void * userdata); 124 125 /** User supplied seek callback. 126 @param offset Offset within the stream to seek to. 127 @param whence Seek direction. One of #NESTEGG_SEEK_SET, 128 #NESTEGG_SEEK_CUR, or #NESTEGG_SEEK_END. 129 @param userdata The #userdata supplied by the user. 130 @retval 0 Seek succeeded. 131 @retval -1 Error. */ 132 int (* seek)(int64_t offset, int whence, void * userdata); 133 134 /** User supplied tell callback. 135 @param userdata The #userdata supplied by the user. 136 @returns Current position within the stream. 137 @retval -1 Error. */ 138 int64_t (* tell)(void * userdata); 139 140 /** User supplied pointer to be passed to the IO callbacks. */ 141 void * userdata; 142 } nestegg_io; 143 144 /** Parameters specific to a video track. */ 145 typedef struct { 146 unsigned int stereo_mode; /**< Video mode. One of #NESTEGG_VIDEO_MONO, 147 #NESTEGG_VIDEO_STEREO_LEFT_RIGHT, 148 #NESTEGG_VIDEO_STEREO_BOTTOM_TOP, or 149 #NESTEGG_VIDEO_STEREO_TOP_BOTTOM. */ 150 unsigned int width; /**< Width of the video frame in pixels. */ 151 unsigned int height; /**< Height of the video frame in pixels. */ 152 unsigned int display_width; /**< Display width of the video frame in pixels. */ 153 unsigned int display_height; /**< Display height of the video frame in pixels. */ 154 unsigned int crop_bottom; /**< Pixels to crop from the bottom of the frame. */ 155 unsigned int crop_top; /**< Pixels to crop from the top of the frame. */ 156 unsigned int crop_left; /**< Pixels to crop from the left of the frame. */ 157 unsigned int crop_right; /**< Pixels to crop from the right of the frame. */ 158 unsigned int alpha_mode; /**< 1 if an additional opacity stream is available, otherwise 0. */ 159 unsigned int matrix_coefficients; /**< See Table 4 of ISO/IEC 23001-8:2016. */ 160 unsigned int range; /**< Clipping of color ranges. */ 161 unsigned int transfer_characteristics; /**< See Table 3 of ISO/IEC 23091-4. */ 162 unsigned int primaries; /**< See Table 2 of ISO/IEC 23091-4. */ 163 double primary_r_chromacity_x; /**< Red X chromaticity coordinate per CIE 1931. 164 NaN means element not present. */ 165 double primary_r_chromacity_y; /**< Red Y chromaticity coordinate per CIE 1931. 166 NaN means element not present. */ 167 double primary_g_chromacity_x; /**< Green X chromaticity coordinate per CIE 1931. 168 NaN means element not present. */ 169 double primary_g_chromacity_y; /**< Green Y chromaticity coordinate per CIE 1931. 170 NaN means element not present. */ 171 double primary_b_chromacity_x; /**< Blue X chromaticity coordinate per CIE 1931. 172 NaN means element not present. */ 173 double primary_b_chromacity_y; /**< Blue Y chromaticity coordinate per CIE 1931. 174 NaN means element not present. */ 175 double white_point_chromaticity_x; /**< White X chromaticity coordinate per CIE 1931. 176 NaN means element not present. */ 177 double white_point_chromaticity_y; /**< White Y chromaticity coordinate per CIE 1931. 178 NaN means element not present. */ 179 double luminance_max; /**< Maximum luminance in cd/m2. 180 NaN means element not present. */ 181 double luminance_min; /**< Minimum luminance in cd/m2. 182 NaN means element not present. */ 183 } nestegg_video_params; 184 185 /** Parameters specific to an audio track. */ 186 typedef struct { 187 double rate; /**< Sampling rate in Hz. */ 188 unsigned int channels; /**< Number of audio channels. */ 189 unsigned int depth; /**< Bits per sample. */ 190 uint64_t codec_delay; /**< Nanoseconds that must be discarded from the start. */ 191 uint64_t seek_preroll;/**< Nanoseconds that must be discarded after a seek. */ 192 } nestegg_audio_params; 193 194 /** Logging callback function pointer. */ 195 typedef void (* nestegg_log)(nestegg * context, unsigned int severity, char const * format, ...); 196 197 /** Initialize a nestegg context. During initialization the parser will 198 read forward in the stream processing all elements until the first 199 block of media is reached. All track metadata has been processed at this point. 200 @param context Storage for the new nestegg context. @see nestegg_destroy 201 @param io User supplied IO context. 202 @param callback Optional logging callback function pointer. May be NULL. 203 @param max_offset Optional maximum offset to be read. Set -1 to ignore. 204 @retval 0 Success. 205 @retval -1 Error. */ 206 int nestegg_init(nestegg ** context, nestegg_io io, nestegg_log callback, int64_t max_offset); 207 208 /** Destroy a nestegg context and free associated memory. 209 @param context #nestegg context to be freed. @see nestegg_init */ 210 void nestegg_destroy(nestegg * context); 211 212 /** Query the duration of the media stream in nanoseconds. 213 @param context Stream context initialized by #nestegg_init. 214 @param duration Storage for the queried duration. 215 @retval 0 Success. 216 @retval -1 Error. */ 217 int nestegg_duration(nestegg * context, uint64_t * duration); 218 219 /** Query the tstamp scale of the media stream in nanoseconds. 220 @note Timestamps presented by nestegg have been scaled by this value 221 before presentation to the caller. 222 @param context Stream context initialized by #nestegg_init. 223 @param scale Storage for the queried scale factor. 224 @retval 0 Success. 225 @retval -1 Error. */ 226 int nestegg_tstamp_scale(nestegg * context, uint64_t * scale); 227 228 /** Query the number of tracks in the media stream. 229 @param context Stream context initialized by #nestegg_init. 230 @param tracks Storage for the queried track count. 231 @retval 0 Success. 232 @retval -1 Error. */ 233 int nestegg_track_count(nestegg * context, unsigned int * tracks); 234 235 /** Query the start and end offset for a particular cluster. 236 @param context Stream context initialized by #nestegg_init. 237 @param cluster_num Zero-based cluster number; order they appear in cues. 238 @param max_offset Optional maximum offset to be read. Set -1 to ignore. 239 @param start_pos Starting offset of the cluster. -1 means non-existant. 240 @param end_pos Starting offset of the cluster. -1 means non-existant or 241 final cluster. 242 @param tstamp Starting timestamp of the cluster. 243 @retval 0 Success. 244 @retval -1 Error. */ 245 int nestegg_get_cue_point(nestegg * context, unsigned int cluster_num, 246 int64_t max_offset, int64_t * start_pos, 247 int64_t * end_pos, uint64_t * tstamp); 248 249 /** Seek to @a offset. Stream will seek directly to offset. 250 Must be used to seek to the start of a cluster; the parser will not be 251 able to understand other offsets. 252 @param context Stream context initialized by #nestegg_init. 253 @param offset Absolute offset in bytes. 254 @retval 0 Success. 255 @retval -1 Error. */ 256 int nestegg_offset_seek(nestegg * context, uint64_t offset); 257 258 /** Seek @a track to @a tstamp. Stream seek will terminate at the earliest 259 key point in the stream at or before @a tstamp. Other tracks in the 260 stream will output packets with unspecified but nearby timestamps. 261 @param context Stream context initialized by #nestegg_init. 262 @param track Zero based track number. 263 @param tstamp Absolute timestamp in nanoseconds. 264 @retval 0 Success. 265 @retval -1 Error. */ 266 int nestegg_track_seek(nestegg * context, unsigned int track, uint64_t tstamp); 267 268 /** Query the type specified by @a track. 269 @param context Stream context initialized by #nestegg_init. 270 @param track Zero based track number. 271 @retval #NESTEGG_TRACK_VIDEO Track type is video. 272 @retval #NESTEGG_TRACK_AUDIO Track type is audio. 273 @retval #NESTEGG_TRACK_UNKNOWN Track type is unknown. 274 @retval -1 Error. */ 275 int nestegg_track_type(nestegg * context, unsigned int track); 276 277 /** Query the codec ID specified by @a track. 278 @param context Stream context initialized by #nestegg_init. 279 @param track Zero based track number. 280 @retval #NESTEGG_CODEC_VP8 Track codec is VP8. 281 @retval #NESTEGG_CODEC_VP9 Track codec is VP9. 282 @retval #NESTEGG_CODEC_AV1 Track codec is AV1. 283 @retval #NESTEGG_CODEC_VORBIS Track codec is Vorbis. 284 @retval #NESTEGG_CODEC_OPUS Track codec is Opus. 285 @retval #NESTEGG_CODEC_UNKNOWN Track codec is unknown. 286 @retval -1 Error. */ 287 int nestegg_track_codec_id(nestegg * context, unsigned int track); 288 289 /** Query the number of codec initialization chunks for @a track. Each 290 chunk of data should be passed to the codec initialization functions in 291 the order returned. 292 @param context Stream context initialized by #nestegg_init. 293 @param track Zero based track number. 294 @param count Storage for the queried chunk count. 295 @retval 0 Success. 296 @retval -1 Error. */ 297 int nestegg_track_codec_data_count(nestegg * context, unsigned int track, 298 unsigned int * count); 299 300 /** Get a pointer to chunk number @a item of codec initialization data for 301 @a track. 302 @param context Stream context initialized by #nestegg_init. 303 @param track Zero based track number. 304 @param item Zero based chunk item number. 305 @param data Storage for the queried data pointer. 306 The data is owned by the #nestegg context. 307 @param length Storage for the queried data size. 308 @retval 0 Success. 309 @retval -1 Error. */ 310 int nestegg_track_codec_data(nestegg * context, unsigned int track, unsigned int item, 311 unsigned char ** data, size_t * length); 312 313 /** Query the video parameters specified by @a track. 314 @param context Stream context initialized by #nestegg_init. 315 @param track Zero based track number. 316 @param params Storage for the queried video parameters. 317 @retval 0 Success. 318 @retval -1 Error. */ 319 int nestegg_track_video_params(nestegg * context, unsigned int track, 320 nestegg_video_params * params); 321 322 /** Query the audio parameters specified by @a track. 323 @param context Stream context initialized by #nestegg_init. 324 @param track Zero based track number. 325 @param params Storage for the queried audio parameters. 326 @retval 0 Success. 327 @retval -1 Error. */ 328 int nestegg_track_audio_params(nestegg * context, unsigned int track, 329 nestegg_audio_params * params); 330 331 /** Query the encoding status for @a track. If a track has multiple encodings 332 the first will be returned. 333 @param context Stream context initialized by #nestegg_init. 334 @param track Zero based track number. 335 @retval #NESTEGG_ENCODING_COMPRESSION The track is compressed, but not encrypted. 336 @retval #NESTEGG_ENCODING_ENCRYPTION The track is encrypted and compressed. 337 @retval -1 Error. */ 338 int nestegg_track_encoding(nestegg * context, unsigned int track); 339 340 /** Query the ContentEncKeyId for @a track. Will return an error if the track 341 in not encrypted, or is not recognized. 342 @param context Stream context initialized by #nestegg_init. 343 @param track Zero based track number. 344 @param content_enc_key_id Storage for queried id. The content encryption key used. 345 Owned by nestegg and will be freed separately. 346 @param content_enc_key_id_length Length of the queried ContentEncKeyId in bytes. 347 @retval 0 Success. 348 @retval -1 Error. */ 349 int nestegg_track_content_enc_key_id(nestegg * context, unsigned int track, 350 unsigned char const ** content_enc_key_id, 351 size_t * content_enc_key_id_length); 352 353 /** Query the default frame duration for @a track. For a video track, this 354 is typically the inverse of the video frame rate. 355 @param context Stream context initialized by #nestegg_init. 356 @param track Zero based track number. 357 @param duration Storage for the default duration in nanoseconds. 358 @retval 0 Success. 359 @retval -1 Error. */ 360 int nestegg_track_default_duration(nestegg * context, unsigned int track, 361 uint64_t * duration); 362 363 /** Reset parser state to the last valid state before nestegg_read_packet failed. 364 @param context Stream context initialized by #nestegg_init. 365 @retval 0 Success. 366 @retval -1 Error. */ 367 int nestegg_read_reset(nestegg * context); 368 369 /** Read a packet of media data. A packet consists of one or more chunks of 370 data associated with a single track. nestegg_read_packet should be 371 called in a loop while the return value is 1 to drive the stream parser 372 forward. @see nestegg_free_packet 373 @param context Context returned by #nestegg_init. 374 @param packet Storage for the returned nestegg_packet. 375 @retval 1 Additional packets may be read in subsequent calls. 376 @retval 0 End of stream. 377 @retval -1 Error. */ 378 int nestegg_read_packet(nestegg * context, nestegg_packet ** packet); 379 380 /** Read the last packet for a track without affecting current parser state. 381 @param context Stream context initialized by #nestegg_init. 382 @param track Zero based track number. 383 @param packet Storage for the returned nestegg_packet. 384 @retval 0 Success. 385 @retval -1 Error. */ 386 int nestegg_read_last_packet(nestegg * context, 387 unsigned int track, 388 nestegg_packet ** packet); 389 390 /** Read total frame count for a track without affecting current parser state.\ 391 This MUST be called before any call to nestegg_read_packet! 392 @param context Stream context initialized by #nestegg_init. 393 @param frames_out Storage for the returned total frames count. 394 @retval 0 Success. 395 @retval -1 Error. */ 396 int nestegg_read_total_frames_count(nestegg * context, uint64_t * frames_out); 397 398 /** Destroy a nestegg_packet and free associated memory. 399 @param packet #nestegg_packet to be freed. @see nestegg_read_packet */ 400 void nestegg_free_packet(nestegg_packet * packet); 401 402 /** Query the keyframe status for a given packet. 403 @param packet Packet initialized by #nestegg_read_packet. 404 @retval #NESTEGG_PACKET_HAS_KEYFRAME_FALSE Packet contains no keyframes. 405 @retval #NESTEGG_PACKET_HAS_KEYFRAME_TRUE Packet contains keyframes. 406 @retval #NESTEGG_PACKET_HAS_KEYFRAME_UNKNOWN Unknown packet keyframe content. 407 @retval -1 Error. */ 408 int nestegg_packet_has_keyframe(nestegg_packet * packet); 409 410 /** Query the track number of @a packet. 411 @param packet Packet initialized by #nestegg_read_packet. 412 @param track Storage for the queried zero based track index. 413 @retval 0 Success. 414 @retval -1 Error. */ 415 int nestegg_packet_track(nestegg_packet * packet, unsigned int * track); 416 417 /** Query the timestamp in nanoseconds of @a packet. 418 @param packet Packet initialized by #nestegg_read_packet. 419 @param tstamp Storage for the queried timestamp in nanoseconds. 420 @retval 0 Success. 421 @retval -1 Error. */ 422 int nestegg_packet_tstamp(nestegg_packet * packet, uint64_t * tstamp); 423 424 /** Query the duration in nanoseconds of @a packet. 425 @param packet Packet initialized by #nestegg_read_packet. 426 @param duration Storage for the queried duration in nanoseconds. 427 @retval 0 Success. 428 @retval -1 Error. */ 429 int nestegg_packet_duration(nestegg_packet * packet, uint64_t * duration); 430 431 /** Query the number of data chunks contained in @a packet. 432 @param packet Packet initialized by #nestegg_read_packet. 433 @param count Storage for the queried chunk count. 434 @retval 0 Success. 435 @retval -1 Error. */ 436 int nestegg_packet_count(nestegg_packet * packet, unsigned int * count); 437 438 /** Get a pointer to chunk number @a item of packet data. 439 @param packet Packet initialized by #nestegg_read_packet. 440 @param item Zero based chunk item number. 441 @param data Storage for the queried data pointer. 442 The data is owned by the #nestegg_packet packet. 443 @param length Storage for the queried data size. 444 @retval 0 Success. 445 @retval -1 Error. */ 446 int nestegg_packet_data(nestegg_packet * packet, unsigned int item, 447 unsigned char ** data, size_t * length); 448 449 /** Get a pointer to additional data with identifier @a id of additional packet 450 data. If @a id isn't present in the packet, returns -1. 451 @param packet Packet initialized by #nestegg_read_packet. 452 @param id Codec specific identifer. For VP8, use 1 to get a VP8 encoded 453 frame containing an alpha channel in its Y plane. 454 @param data Storage for the queried data pointer. 455 The data is owned by the #nestegg_packet packet. 456 @param length Storage for the queried data size. 457 @retval 0 Success. 458 @retval -1 Error. */ 459 int nestegg_packet_additional_data(nestegg_packet * packet, unsigned int id, 460 unsigned char ** data, size_t * length); 461 462 /** Returns discard_padding for given packet 463 @param packet Packet initialized by #nestegg_read_packet. 464 @param discard_padding pointer to store discard padding in. 465 @retval 0 Success. 466 @retval -1 Error. */ 467 int nestegg_packet_discard_padding(nestegg_packet * packet, 468 int64_t * discard_padding); 469 470 /** Query if a packet is encrypted. 471 @param packet Packet initialized by #nestegg_read_packet. 472 @retval #NESTEGG_PACKET_HAS_SIGNAL_BYTE_FALSE No signal byte, encryption 473 information not read from packet. 474 @retval #NESTEGG_PACKET_HAS_SIGNAL_BYTE_UNENCRYPTED Encrypted bit not 475 set, encryption information not read from packet. 476 @retval #NESTEGG_PACKET_HAS_SIGNAL_BYTE_ENCRYPTED Encrypted bit set, 477 encryption infomation read from packet. 478 @retval #NESTEGG_PACKET_HAS_SIGNAL_BYTE_PARTITIONED Partitioned bit set, 479 encryption and parition information read from packet. 480 @retval -1 Error.*/ 481 int nestegg_packet_encryption(nestegg_packet * packet); 482 483 /** Query the IV for an encrypted packet. Expects a packet from an encrypted 484 track, and will return error if given a packet that has no signal btye. 485 @param packet Packet initialized by #nestegg_read_packet. 486 @param iv Storage for queried iv. 487 @param length Length of returned iv, may be 0. 488 The data is owned by the #nestegg_packet packet. 489 @retval 0 Success. 490 @retval -1 Error. 491 */ 492 int nestegg_packet_iv(nestegg_packet * packet, unsigned char const ** iv, 493 size_t * length); 494 495 /** Query the packet for offsets. 496 @param packet Packet initialized by #nestegg_read_packet. 497 @param partition_offsets Storage for queried offsets. 498 @param num_offsets Length of returned offsets, may be 0. 499 The data is owned by the #nestegg_packet packet. 500 @retval 0 Success. 501 @retval -1 Error. 502 */ 503 int nestegg_packet_offsets(nestegg_packet * packet, 504 uint32_t const ** partition_offsets, 505 uint8_t * num_offsets); 506 507 /** Returns reference_block given packet 508 @param packet Packet initialized by #nestegg_read_packet. 509 @param reference_block pointer to store reference block in. 510 @retval 0 Success. 511 @retval -1 Error. */ 512 int nestegg_packet_reference_block(nestegg_packet * packet, 513 int64_t * reference_block); 514 515 /** Query the presence of cues. 516 @param context Stream context initialized by #nestegg_init. 517 @retval 0 The media has no cues. 518 @retval 1 The media has cues. */ 519 int nestegg_has_cues(nestegg * context); 520 521 /** Try to determine if the buffer looks like the beginning of a WebM file. 522 @param buffer A buffer containing the beginning of a media file. 523 @param length The size of the buffer. 524 @retval 0 The file is not a WebM file. 525 @retval 1 The file is a WebM file. */ 526 int nestegg_sniff_webm(unsigned char const* buffer, size_t length); 527 528 /** Try to determine if the buffer looks like the beginning of a Mkv file. 529 @param buffer A buffer containing the beginning of a media file. 530 @param length The size of the buffer. 531 @retval 0 The file is not a Mkv file. 532 @retval 1 The file is a Mkv Mkv. */ 533 int nestegg_sniff_mkv(unsigned char const * buffer, size_t length); 534 535 #if defined(__cplusplus) 536 } 537 #endif 538 539 #endif /* NESTEGG_671cac2a_365d_ed69_d7a3_4491d3538d79 */