You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
4.2KB

  1. /*
  2. * "Real" compatible muxer and demuxer.
  3. * Copyright (c) 2000, 2001 Fabrice Bellard.
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #ifndef FFMPEG_RM_H
  22. #define FFMPEG_RM_H
  23. #include <stdint.h>
  24. #include "avformat.h"
  25. typedef struct {
  26. int nb_packets;
  27. int packet_total_size;
  28. int packet_max_size;
  29. /* codec related output */
  30. int bit_rate;
  31. float frame_rate;
  32. int nb_frames; /* current frame number */
  33. int total_frames; /* total number of frames */
  34. int num;
  35. AVCodecContext *enc;
  36. } StreamInfo;
  37. typedef struct {
  38. StreamInfo streams[2];
  39. StreamInfo *audio_stream, *video_stream;
  40. int data_pos; /* position of the data after the header */
  41. int nb_packets;
  42. int old_format;
  43. int current_stream;
  44. int remaining_len;
  45. uint8_t *videobuf; ///< place to store merged video frame
  46. int videobufsize; ///< current assembled frame size
  47. int videobufpos; ///< position for the next slice in the video buffer
  48. int curpic_num; ///< picture number of current frame
  49. int cur_slice, slices;
  50. int64_t pktpos; ///< first slice position in file
  51. /// Audio descrambling matrix parameters
  52. uint8_t *audiobuf; ///< place to store reordered audio data
  53. int64_t audiotimestamp; ///< Audio packet timestamp
  54. int sub_packet_cnt; // Subpacket counter, used while reading
  55. int sub_packet_size, sub_packet_h, coded_framesize; ///< Descrambling parameters from container
  56. int audio_stream_num; ///< Stream number for audio packets
  57. int audio_pkt_cnt; ///< Output packet counter
  58. int audio_framesize; /// Audio frame size from container
  59. int sub_packet_lengths[16]; /// Length of each aac subpacket
  60. } RMContext;
  61. /**
  62. * Read the MDPR chunk, which contains stream-specific codec initialization
  63. * parameters.
  64. *
  65. * @param s context containing RMContext and ByteIOContext for stream reading
  66. * @param st the stream that the MDPR chunk belongs to and where to store the
  67. * parameters read from the chunk into
  68. * @return 0 on success, errno codes on error
  69. */
  70. int ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVStream *st);
  71. /**
  72. * Parse one rm-stream packet from the input bytestream.
  73. *
  74. * @param s context containing RMContext and ByteIOContext for stream reading
  75. * @param st stream to which the packet to be read belongs
  76. * @param len packet length to read from the input
  77. * @param pkt packet location to store the parsed packet data
  78. * @param seq pointer to an integer containing the sequence number, may be
  79. * updated
  80. * @param flags pointer to an integer containing the packet flags, may be
  81. updated
  82. * @param ts pointer to timestamp, may be updated
  83. * @return 0 on success, errno codes on error
  84. */
  85. int ff_rm_parse_packet (AVFormatContext *s, AVStream *st, int len,
  86. AVPacket *pkt, int *seq, int *flags, int64_t *ts);
  87. /**
  88. * Retrieve one cached packet from the rm-context. The real container can
  89. * store several packets (as interpreted by the codec) in a single container
  90. * packet, which means the demuxer holds some back when the first container
  91. * packet is parsed and returned. The result is that rm->audio_pkt_cnt is
  92. * a positive number, the amount of cached packets. Using this function, each
  93. * of those packets can be retrieved sequentially.
  94. *
  95. * @param s context containing RMContext and ByteIOContext for stream reading
  96. * @param st stream that this packet belongs to
  97. * @param pkt location to store the packet data
  98. */
  99. void ff_rm_retrieve_cache (AVFormatContext *s, AVStream *st, AVPacket *pkt);
  100. #endif /* FFMPEG_RM_H */