*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
-
+#include "crc.h"
#include "mpegts.h"
//#define DEBUG_SI
if (tss->section_h_size != -1 && tss->section_index >= tss->section_h_size) {
tss->end_of_section_reached = 1;
if (!tss->check_crc ||
- mpegts_crc32(tss->section_buf, tss->section_h_size) == 0)
+ av_crc(av_crc04C11DB7, -1, tss->section_buf, tss->section_h_size) == 0)
tss->section_cb(tss->opaque, tss->section_buf, tss->section_h_size);
}
}
-MpegTSFilter *mpegts_open_section_filter(MpegTSContext *ts, unsigned int pid,
+static MpegTSFilter *mpegts_open_section_filter(MpegTSContext *ts, unsigned int pid,
SectionCallback *section_cb, void *opaque,
int check_crc)
return filter;
}
-MpegTSFilter *mpegts_open_pes_filter(MpegTSContext *ts, unsigned int pid,
+static MpegTSFilter *mpegts_open_pes_filter(MpegTSContext *ts, unsigned int pid,
PESCallback *pes_cb,
void *opaque)
{
return filter;
}
-void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter)
+static void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter)
{
int pid;
desc_tag = get8(&p, desc_list_end);
if (desc_tag < 0)
break;
+ if (stream_type == STREAM_TYPE_PRIVATE_DATA) {
+ if((desc_tag == 0x6A) || (desc_tag == 0x7A)) {
+ /*assume DVB AC-3 Audio*/
+ stream_type = STREAM_TYPE_AUDIO_AC3;
+ } else if(desc_tag == 0x7B) {
+ /* DVB DTS audio */
+ stream_type = STREAM_TYPE_AUDIO_DTS;
+ }
+ }
desc_len = get8(&p, desc_list_end);
desc_end = p + desc_len;
if (desc_end > desc_list_end)
ts->pat_filter = NULL;
}
-void mpegts_set_service(MpegTSContext *ts, int sid,
+static void mpegts_set_service(MpegTSContext *ts, int sid,
SetServiceCallback *set_service_cb, void *opaque)
{
ts->set_service_cb = set_service_cb;
}
/* scan services in a transport stream by looking at the SDT */
-void mpegts_scan_sdt(MpegTSContext *ts)
+static void mpegts_scan_sdt(MpegTSContext *ts)
{
ts->sdt_filter = mpegts_open_section_filter(ts, SDT_PID,
sdt_cb, ts, 1);
/* scan services in a transport stream by looking at the PAT (better
than nothing !) */
-void mpegts_scan_pat(MpegTSContext *ts)
+static void mpegts_scan_pat(MpegTSContext *ts)
{
ts->pat_filter = mpegts_open_section_filter(ts, PAT_PID,
pat_scan_cb, ts, 1);
ts->stream = s;
ts->auto_guess = 0;
+goto_auto_guess:
if (!ts->mpeg2ts_raw) {
/* normal demux */
}
/* if could not find service, exit */
- if (ts->set_service_ret != 0)
- return -1;
+ if (ts->set_service_ret != 0) {
+ if(ts->auto_guess)
+ return -1;
+ else {
+ //let's retry with auto_guess set
+ ts->auto_guess = 1;
+ goto goto_auto_guess;
+ }
+ }
#ifdef DEBUG_SI
printf("tuning done\n");
int i;
for(i=0;i<NB_PID_MAX;i++)
if (ts->pids[i]) mpegts_close_filter(ts, ts->pids[i]);
+
+ for(i = 0; i < ts->nb_services; i++){
+ av_free(ts->services[i]->provider_name);
+ av_free(ts->services[i]->name);
+ av_free(ts->services[i]);
+ }
+ av_freep(&ts->services);
+
return 0;
}
av_free(ts);
}
-AVInputFormat mpegts_demux = {
+AVInputFormat mpegts_demuxer = {
"mpegts",
"MPEG2 transport stream format",
sizeof(MpegTSContext),
mpegts_get_pcr,
.flags = AVFMT_SHOW_IDS,
};
-
-int mpegts_init(void)
-{
- av_register_input_format(&mpegts_demux);
-#ifdef CONFIG_MUXERS
- av_register_output_format(&mpegts_mux);
-#endif
- return 0;
-}