Esempio n. 1
0
static int mpeg2dec_codec_check (lib_message_func_t message,
				 const char *stream_type,
			     const char *compressor,
			     int type,
			     int profile,
			     format_list_t *fptr,
			     const uint8_t *userdata,
			     uint32_t userdata_size,
			      CConfigSet *pConfig)
{
  int ret_val = 3;

  if (strcasecmp(stream_type, STREAM_TYPE_RTP) == 0 &&
      fptr != NULL) {
    if (strcmp(fptr->fmt, "32") == 0) {
      return ret_val;
    }
  }
  if (strcasecmp(stream_type, STREAM_TYPE_MPEG_FILE) == 0) {
    if (type == MPEG_VIDEO_MPEG1 || type == MPEG_VIDEO_MPEG2)
      return ret_val;
  }
  if (strcasecmp(stream_type, STREAM_TYPE_MPEG2_TRANSPORT_STREAM) == 0) {
    if ((type == MPEG2T_ST_MPEG_VIDEO) ||
	(type == MPEG2T_ST_11172_VIDEO)) 
      return ret_val;
  }
  if (strcasecmp(stream_type, STREAM_TYPE_MP4_FILE) == 0) {
    if (strcasecmp(compressor, "mp4v") == 0 &&
	(MP4_IS_MPEG1_VIDEO_TYPE(type) ||
	 MP4_IS_MPEG2_VIDEO_TYPE(type))) return ret_val;
  }
  return -1;
}
Esempio n. 2
0
//#define DEBUG_FFMPEG_FRAME 1
//#define DEBUG_FFMPEG_PTS 1
static enum CodecID ffmpeg_find_codec (const char *stream_type,
                                       const char *compressor,
                                       int type,
                                       int profile,
                                       format_list_t *fptr,
                                       const uint8_t *userdata,
                                       uint32_t ud_size)
{
    bool have_mp4_file = strcasecmp(stream_type, STREAM_TYPE_MP4_FILE) == 0;

    if (have_mp4_file) {
        if (strcasecmp(compressor, "avc1") == 0) {
            return CODEC_ID_H264;
        }
        if (strcasecmp(compressor, "mp4v") == 0) {
            if (MP4_IS_MPEG1_VIDEO_TYPE(type) ||
                    MP4_IS_MPEG2_VIDEO_TYPE(type))
                return CODEC_ID_MPEG2VIDEO;
            if (MP4_IS_MPEG4_VIDEO_TYPE(type))
                return CODEC_ID_MPEG4;
        }
    }
    if (have_mp4_file ||
            strcasecmp(stream_type, "QT FILE") == 0) {
        if (strcasecmp(compressor, "h263") == 0 ||
                strcasecmp(compressor, "s263") == 0) {
            return CODEC_ID_H263;
        }
        if (strcasecmp(compressor, "SVQ3") == 0) {
            return CODEC_ID_SVQ3;
        }
        if (strcasecmp(compressor, "jpeg") == 0) {
            return CODEC_ID_MJPEG;
        }
        return CODEC_ID_NONE;
    }
    if (strcasecmp(stream_type, STREAM_TYPE_MPEG_FILE) == 0) {
        if (type == MPEG_VIDEO_H264) return CODEC_ID_H264;
        return CODEC_ID_MPEG2VIDEO;
    }

    if (strcasecmp(stream_type, STREAM_TYPE_MPEG2_TRANSPORT_STREAM) == 0) {
        if ((type == MPEG2T_ST_MPEG_VIDEO) ||
                (type == MPEG2T_ST_11172_VIDEO))
            return CODEC_ID_MPEG2VIDEO;
        if (type == MPEG2T_ST_H264_VIDEO) {
            return CODEC_ID_H264;
        }
        return CODEC_ID_NONE;
    }

    if (strcasecmp(stream_type, STREAM_TYPE_AVI_FILE) == 0) {
        if (strcasecmp(compressor, "vssh") == 0) {
            return CODEC_ID_H264;
        }
        if (strcasecmp(compressor, "H263") == 0) {
            return CODEC_ID_H263;
        }
        if (strcasecmp(compressor, "mjpg") == 0) {
            return CODEC_ID_MJPEG;
        }
        return CODEC_ID_NONE;
    }
    if (strcasecmp(stream_type, "QT FILE") == 0) {
        if (strcasecmp(compressor, "h263") == 0 ||
                strcasecmp(compressor, "s263") == 0) {
            return CODEC_ID_H263;
        }
        return CODEC_ID_NONE;
    }
    if ((strcasecmp(stream_type, STREAM_TYPE_RTP) == 0) && fptr != NULL) {
        if (strcmp(fptr->fmt, "32") == 0)
            return CODEC_ID_MPEG2VIDEO;
        if (fptr->rtpmap != NULL) {
            if (strcasecmp(fptr->rtpmap->encode_name, "h263-1998") == 0 ||
                    strcasecmp(fptr->rtpmap->encode_name, "h263-2000") == 0) {
                return CODEC_ID_H263;
            }
            if (strcasecmp(fptr->rtpmap->encode_name, "MP4V-ES") == 0) {
                // may want to check level and profile
                return CODEC_ID_MPEG4;
            }
            if (strcasecmp(fptr->rtpmap->encode_name, "h264") == 0) {
                // may want to check for sprop-parameters
                return CODEC_ID_H264;
            }
        }
        return CODEC_ID_NONE;
    }
    return CODEC_ID_NONE;
}