正在显示
2 个修改的文件
包含
167 行增加
和
5 行删除
| @@ -363,3 +363,62 @@ SrsMp4CompositionTime2SampleBox::~SrsMp4CompositionTime2SampleBox() | @@ -363,3 +363,62 @@ SrsMp4CompositionTime2SampleBox::~SrsMp4CompositionTime2SampleBox() | ||
| 363 | srs_freepa(entries); | 363 | srs_freepa(entries); |
| 364 | } | 364 | } |
| 365 | 365 | ||
| 366 | +SrsMp4SyncSampleBox::SrsMp4SyncSampleBox() | ||
| 367 | +{ | ||
| 368 | + type = 0x73747373; // 'stss' | ||
| 369 | + | ||
| 370 | + entry_count = 0; | ||
| 371 | + sample_numbers = NULL; | ||
| 372 | +} | ||
| 373 | + | ||
| 374 | +SrsMp4SyncSampleBox::~SrsMp4SyncSampleBox() | ||
| 375 | +{ | ||
| 376 | + srs_freepa(sample_numbers); | ||
| 377 | +} | ||
| 378 | + | ||
| 379 | +SrsMp4StscEntry::SrsMp4StscEntry() | ||
| 380 | +{ | ||
| 381 | + first_chunk = 0; | ||
| 382 | + samples_per_chunk = 0; | ||
| 383 | + sample_description_index = 0; | ||
| 384 | +} | ||
| 385 | + | ||
| 386 | +SrsMp4Sample2ChunkBox::SrsMp4Sample2ChunkBox() | ||
| 387 | +{ | ||
| 388 | + type = 0x73747363; // 'stsc' | ||
| 389 | + | ||
| 390 | + entry_count = 0; | ||
| 391 | + entries = NULL; | ||
| 392 | +} | ||
| 393 | + | ||
| 394 | +SrsMp4Sample2ChunkBox::~SrsMp4Sample2ChunkBox() | ||
| 395 | +{ | ||
| 396 | + srs_freepa(entries); | ||
| 397 | +} | ||
| 398 | + | ||
| 399 | +SrsMp4ChunkOffsetBox::SrsMp4ChunkOffsetBox() | ||
| 400 | +{ | ||
| 401 | + type = 0x7374636f; // 'stco' | ||
| 402 | + | ||
| 403 | + entry_count = 0; | ||
| 404 | + entries = NULL; | ||
| 405 | +} | ||
| 406 | + | ||
| 407 | +SrsMp4ChunkOffsetBox::~SrsMp4ChunkOffsetBox() | ||
| 408 | +{ | ||
| 409 | + srs_freepa(entries); | ||
| 410 | +} | ||
| 411 | + | ||
| 412 | +SrsMp4SampleSizeBox::SrsMp4SampleSizeBox() | ||
| 413 | +{ | ||
| 414 | + type = 0x7374737a; // 'stsz' | ||
| 415 | + | ||
| 416 | + sample_size = sample_count = 0; | ||
| 417 | + entry_sizes = NULL; | ||
| 418 | +} | ||
| 419 | + | ||
| 420 | +SrsMp4SampleSizeBox::~SrsMp4SampleSizeBox() | ||
| 421 | +{ | ||
| 422 | + srs_freepa(entry_sizes); | ||
| 423 | +} | ||
| 424 | + |
| @@ -568,7 +568,7 @@ public: | @@ -568,7 +568,7 @@ public: | ||
| 568 | }; | 568 | }; |
| 569 | 569 | ||
| 570 | /** | 570 | /** |
| 571 | - * 8.5.2 Sample Description Box (stsd) | 571 | + * 8.5.2 Sample Description Box (stsd), for Audio/Video. |
| 572 | * ISO_IEC_14496-12-base-format-2012.pdf, page 40 | 572 | * ISO_IEC_14496-12-base-format-2012.pdf, page 40 |
| 573 | * The sample description table gives detailed information about the coding type used, and any initialization | 573 | * The sample description table gives detailed information about the coding type used, and any initialization |
| 574 | * information needed for that coding. | 574 | * information needed for that coding. |
| @@ -585,7 +585,7 @@ public: | @@ -585,7 +585,7 @@ public: | ||
| 585 | }; | 585 | }; |
| 586 | 586 | ||
| 587 | /** | 587 | /** |
| 588 | - * 8.6.1.2 Decoding Time to Sample Box (stts) | 588 | + * 8.6.1.2 Decoding Time to Sample Box (stts), for Audio/Video. |
| 589 | * ISO_IEC_14496-12-base-format-2012.pdf, page 48 | 589 | * ISO_IEC_14496-12-base-format-2012.pdf, page 48 |
| 590 | */ | 590 | */ |
| 591 | struct SrsMp4SttsEntry | 591 | struct SrsMp4SttsEntry |
| @@ -600,7 +600,7 @@ struct SrsMp4SttsEntry | @@ -600,7 +600,7 @@ struct SrsMp4SttsEntry | ||
| 600 | }; | 600 | }; |
| 601 | 601 | ||
| 602 | /** | 602 | /** |
| 603 | - * 8.6.1.2 Decoding Time to Sample Box (stts) | 603 | + * 8.6.1.2 Decoding Time to Sample Box (stts), for Audio/Video. |
| 604 | * ISO_IEC_14496-12-base-format-2012.pdf, page 48 | 604 | * ISO_IEC_14496-12-base-format-2012.pdf, page 48 |
| 605 | * This box contains a compact version of a table that allows indexing from decoding time to sample number. | 605 | * This box contains a compact version of a table that allows indexing from decoding time to sample number. |
| 606 | * Other tables give sample sizes and pointers, from the sample number. Each entry in the table gives the | 606 | * Other tables give sample sizes and pointers, from the sample number. Each entry in the table gives the |
| @@ -620,7 +620,7 @@ public: | @@ -620,7 +620,7 @@ public: | ||
| 620 | 620 | ||
| 621 | 621 | ||
| 622 | /** | 622 | /** |
| 623 | - * 8.6.1.3 Composition Time to Sample Box (ctts) | 623 | + * 8.6.1.3 Composition Time to Sample Box (ctts), for Video. |
| 624 | * ISO_IEC_14496-12-base-format-2012.pdf, page 49 | 624 | * ISO_IEC_14496-12-base-format-2012.pdf, page 49 |
| 625 | */ | 625 | */ |
| 626 | struct SrsMp4CttsEntry | 626 | struct SrsMp4CttsEntry |
| @@ -637,7 +637,7 @@ struct SrsMp4CttsEntry | @@ -637,7 +637,7 @@ struct SrsMp4CttsEntry | ||
| 637 | }; | 637 | }; |
| 638 | 638 | ||
| 639 | /** | 639 | /** |
| 640 | - * 8.6.1.3 Composition Time to Sample Box (ctts) | 640 | + * 8.6.1.3 Composition Time to Sample Box (ctts), for Video. |
| 641 | * ISO_IEC_14496-12-base-format-2012.pdf, page 49 | 641 | * ISO_IEC_14496-12-base-format-2012.pdf, page 49 |
| 642 | * This box provides the offset between decoding time and composition time. In version 0 of this box the | 642 | * This box provides the offset between decoding time and composition time. In version 0 of this box the |
| 643 | * decoding time must be less than the composition time, and the offsets are expressed as unsigned numbers | 643 | * decoding time must be less than the composition time, and the offsets are expressed as unsigned numbers |
| @@ -657,5 +657,108 @@ public: | @@ -657,5 +657,108 @@ public: | ||
| 657 | virtual ~SrsMp4CompositionTime2SampleBox(); | 657 | virtual ~SrsMp4CompositionTime2SampleBox(); |
| 658 | }; | 658 | }; |
| 659 | 659 | ||
| 660 | +/** | ||
| 661 | + * 8.6.2 Sync Sample Box (stss), for Video. | ||
| 662 | + * ISO_IEC_14496-12-base-format-2012.pdf, page 51 | ||
| 663 | + * This box provides a compact marking of the sync samples within the stream. The table is arranged in strictly | ||
| 664 | + * increasing order of sample number. | ||
| 665 | + */ | ||
| 666 | +class SrsMp4SyncSampleBox : public SrsMp4FullBox | ||
| 667 | +{ | ||
| 668 | +public: | ||
| 669 | + // an integer that gives the number of entries in the following table. If entry_count is zero, | ||
| 670 | + // there are no sync samples within the stream and the following table is empty. | ||
| 671 | + uint32_t entry_count; | ||
| 672 | + // the numbers of the samples that are sync samples in the stream. | ||
| 673 | + uint32_t* sample_numbers; | ||
| 674 | +public: | ||
| 675 | + SrsMp4SyncSampleBox(); | ||
| 676 | + virtual ~SrsMp4SyncSampleBox(); | ||
| 677 | +}; | ||
| 678 | + | ||
| 679 | +/** | ||
| 680 | + * 8.7.4 Sample To Chunk Box (stsc), for Audio/Video. | ||
| 681 | + * ISO_IEC_14496-12-base-format-2012.pdf, page 58 | ||
| 682 | + */ | ||
| 683 | +struct SrsMp4StscEntry | ||
| 684 | +{ | ||
| 685 | + // an integer that gives the index of the first chunk in this run of chunks that share the | ||
| 686 | + // same samples-per-chunk and sample-description-index; the index of the first chunk in a track has the | ||
| 687 | + // value 1 (the first_chunk field in the first record of this box has the value 1, identifying that the first | ||
| 688 | + // sample maps to the first chunk). | ||
| 689 | + uint32_t first_chunk; | ||
| 690 | + // an integer that gives the number of samples in each of these chunks | ||
| 691 | + uint32_t samples_per_chunk; | ||
| 692 | + // an integer that gives the index of the sample entry that describes the | ||
| 693 | + // samples in this chunk. The index ranges from 1 to the number of sample entries in the Sample | ||
| 694 | + // Description Box | ||
| 695 | + uint32_t sample_description_index; | ||
| 696 | + // Constructor | ||
| 697 | + SrsMp4StscEntry(); | ||
| 698 | +}; | ||
| 699 | + | ||
| 700 | +/** | ||
| 701 | + * 8.7.4 Sample To Chunk Box (stsc), for Audio/Video. | ||
| 702 | + * ISO_IEC_14496-12-base-format-2012.pdf, page 58 | ||
| 703 | + * Samples within the media data are grouped into chunks. Chunks can be of different sizes, and the samples | ||
| 704 | + * within a chunk can have different sizes. This table can be used to find the chunk that contains a sample, | ||
| 705 | + * its position, and the associated sample description. | ||
| 706 | + */ | ||
| 707 | +class SrsMp4Sample2ChunkBox : public SrsMp4FullBox | ||
| 708 | +{ | ||
| 709 | +public: | ||
| 710 | + // an integer that gives the number of entries in the following table | ||
| 711 | + uint32_t entry_count; | ||
| 712 | + // the numbers of the samples that are sync samples in the stream. | ||
| 713 | + SrsMp4StscEntry* entries; | ||
| 714 | +public: | ||
| 715 | + SrsMp4Sample2ChunkBox(); | ||
| 716 | + virtual ~SrsMp4Sample2ChunkBox(); | ||
| 717 | +}; | ||
| 718 | + | ||
| 719 | +/** | ||
| 720 | + * 8.7.5 Chunk Offset Box (stco or co64), for Audio/Video. | ||
| 721 | + * ISO_IEC_14496-12-base-format-2012.pdf, page 59 | ||
| 722 | + * The chunk offset table gives the index of each chunk into the containing file. There are two variants, permitting | ||
| 723 | + * the use of 32-bit or 64-bit offsets. The latter is useful when managing very large presentations. At most one of | ||
| 724 | + * these variants will occur in any single instance of a sample table. | ||
| 725 | + */ | ||
| 726 | +class SrsMp4ChunkOffsetBox : public SrsMp4FullBox | ||
| 727 | +{ | ||
| 728 | +public: | ||
| 729 | + // an integer that gives the number of entries in the following table | ||
| 730 | + uint32_t entry_count; | ||
| 731 | + // a 32 or 64 bit integer that gives the offset of the start of a chunk into its containing | ||
| 732 | + // media file. | ||
| 733 | + uint64_t* entries; | ||
| 734 | +public: | ||
| 735 | + SrsMp4ChunkOffsetBox(); | ||
| 736 | + virtual ~SrsMp4ChunkOffsetBox(); | ||
| 737 | +}; | ||
| 738 | + | ||
| 739 | +/** | ||
| 740 | + * 8.7.3 Sample Size Boxes (stsz or stz2), for Audio/Video. | ||
| 741 | + * ISO_IEC_14496-12-base-format-2012.pdf, page 57 | ||
| 742 | + * This box contains the sample count and a table giving the size in bytes of each sample. This allows the media data | ||
| 743 | + * itself to be unframed. The total number of samples in the media is always indicated in the sample count. | ||
| 744 | + */ | ||
| 745 | +class SrsMp4SampleSizeBox : public SrsMp4FullBox | ||
| 746 | +{ | ||
| 747 | +public: | ||
| 748 | + // the default sample size. If all the samples are the same size, this field | ||
| 749 | + // contains that size value. If this field is set to 0, then the samples have different sizes, and those sizes | ||
| 750 | + // are stored in the sample size table. If this field is not 0, it specifies the constant sample size, and no | ||
| 751 | + // array follows. | ||
| 752 | + uint32_t sample_size; | ||
| 753 | + // an integer that gives the number of samples in the track; if sample-size is 0, then it is | ||
| 754 | + // also the number of entries in the following table. | ||
| 755 | + uint32_t sample_count; | ||
| 756 | + // each entry_size is an integer specifying the size of a sample, indexed by its number. | ||
| 757 | + uint32_t* entry_sizes; | ||
| 758 | +public: | ||
| 759 | + SrsMp4SampleSizeBox(); | ||
| 760 | + virtual ~SrsMp4SampleSizeBox(); | ||
| 761 | +}; | ||
| 762 | + | ||
| 660 | #endif | 763 | #endif |
| 661 | 764 |
-
请 注册 或 登录 后发表评论