Beispiel #1
0
//#define DEBUG_RFC3267 1
//#define DEBUG_RFC3267_FRAME 1
static rtp_check_return_t check (lib_message_func_t msg, 
				 format_list_t *fmt, 
				 uint8_t rtp_payload_type,
				 CConfigSet *pConfig)
{

  if (fmt == NULL || fmt->rtpmap == NULL) 
    return RTP_PLUGIN_NO_MATCH;

  if ((strcasecmp(fmt->rtpmap->encode_name, "AMR") != 0) &&
      (strcasecmp(fmt->rtpmap->encode_name, "AMR-WB") != 0)) {
    return RTP_PLUGIN_NO_MATCH;
  }
  const char *interleave = strcasestr(fmt->fmt_param, "interleaving");
  if (interleave != NULL) return RTP_PLUGIN_NO_MATCH;

  const char *octet_align = strcasestr(fmt->fmt_param, "octet-align");
  if (octet_align == NULL) 
    return RTP_PLUGIN_NO_MATCH;

  octet_align += strlen("octet-align");
  ADV_SPACE(octet_align);
  if ((*octet_align == '\0') || *octet_align == ';')
    return RTP_PLUGIN_MATCH;

  if (*octet_align++ != '=') return RTP_PLUGIN_NO_MATCH;
  ADV_SPACE(octet_align);
  if (*octet_align != '1') return RTP_PLUGIN_NO_MATCH;
  return RTP_PLUGIN_MATCH;
}
static rtp_check_return_t check (lib_message_func_t msg, 
				 format_list_t *fmt, 
				 uint8_t rtp_payload_type,
				 CConfigSet *pConfig)
{

  if (fmt == NULL || fmt->rtpmap == NULL || fmt->fmt_param == NULL)
    return RTP_PLUGIN_NO_MATCH;

  if (strcasecmp(fmt->rtpmap->encode_name, "h264") == 0) {
    // see if the fmtp has a packetization-mode parameter
    const char *temp;
    temp = strcasestr(fmt->fmt_param, "packetization-mode");
    if (temp == NULL) {
      return RTP_PLUGIN_MATCH;
    }
    temp += strlen("packetization-mode");
    ADV_SPACE(temp);
    if (*temp != '=') return RTP_PLUGIN_NO_MATCH;
    temp++;
    ADV_SPACE(temp);
    if (*temp == '0' || *temp == '1')
      return RTP_PLUGIN_MATCH;
    // not a packetization-mode that we understand
    msg(LOG_DEBUG, h264rtp, "incorrect packetization mode %c for this version", 
	*temp);
  }

  return RTP_PLUGIN_NO_MATCH;
}
Beispiel #3
0
/*
 * h264_sdp_parse_sprop_param_sets - look for the sprop_param sets in the
 * a=fmtp message passed, create nal units from base64 code.
 * Inputs - fmt_param - a=fmtp: string
 *   nal_len - pointer to return length
 *   message - pointer to output routine
 * Outputs - binary nal string (must be freed by caller)
 */
uint8_t *h264_sdp_parse_sprop_param_sets (const char *fmt_param, 
					  uint32_t *nal_len,
					  lib_message_func_t message)
{
  const char *sprop;
  const char *end;
  uint8_t *bin, *ret;
  uint32_t binsize;

  sprop = strcasestr(fmt_param, "sprop-parameter-sets");

  if (sprop == NULL) {
    if (message != NULL) 
      message(LOG_ERR, "h264sdp", "no sprop-parameter-sets in sdp");
    return NULL;
  }
  sprop += strlen("sprop-parameter-sets");
  ADV_SPACE(sprop);
  if (*sprop != '=') {
    if (message != NULL)
      message(LOG_DEBUG, "h264sdp", "no equals in sprop-parameter-sets");
    return NULL;
  }
  sprop++;
  ADV_SPACE(sprop);
  ret = NULL;
  *nal_len = 0;
  do {
    end = sprop;
    while (*end != ',' && *end != ';' && *end != '\0') end++;
    if (sprop != end) {
      bin = Base64ToBinary(sprop, end - sprop, &binsize);
      if (bin != NULL) {
	ret = (uint8_t *)realloc(ret, *nal_len + binsize + 4);
	if (nal_len == 0) {
	  ret[*nal_len] = 0;
	  *nal_len += 1;
	}
	ret[*nal_len] = 0;
	ret[*nal_len + 1] = 0;
	ret[*nal_len + 2] = 1;
	memcpy(ret + *nal_len + 3, 
	       bin,
	       binsize);
	*nal_len += binsize + 3;
      } else {
	if (message != NULL)
	  message(LOG_ERR, "h264sdp", 
		  "failed to convert %u \"%s\"", 
		  end - sprop, sprop);
      }
    }
	  
    sprop = end;
    if (*sprop == ',') sprop++;
  } while (*sprop != ';' && *sprop != '\0');
  return ret;
}
Beispiel #4
0
  bool EncodeFrame (const char *fptr) {
    ADV_SPACE(fptr);
    CHECK_AND_FREE(m_encodedFrame);
    if (*fptr == 'A' || *fptr == '<') {
      // we have an already formatted href
      const char *check = fptr + 1;
      if (*check == '<') {
	check++;
      }
      if (strncmp(check, m_base_url, m_base_url_len) == 0) {
	check += m_base_url_len;
	m_encodedFrame = (char *)malloc(strlen(check) + 
					*fptr == 'A' ? 2 : 1);
	char *copyto = m_encodedFrame;
	if (*fptr == 'A') {
	  *copyto++ = 'A';
	}
	*copyto++ = '<';
	strcpy(copyto, check);
	debug_message("%s", m_encodedFrame);
      } else {
	m_encodedFrame = strdup(fptr);
      }
      chomp();
    } else {
      // we need to add <> and maybe an A
      uint32_t size = strlen(fptr) + 1; // add \0 at end
      if (strncmp(fptr, m_base_url, m_base_url_len) == 0) {
	fptr += m_base_url_len;
      }
      debug_message("string \"%s\"", fptr);
      size += 2; // add <>
      if (Profile()->GetBoolValue(CFG_TEXT_HREF_MAKE_AUTOMATIC)) size++;
      m_encodedFrame = (char *)malloc(size);
      char *write = m_encodedFrame;
      if (Profile()->GetBoolValue(CFG_TEXT_HREF_MAKE_AUTOMATIC)) {
	*write++ = 'A';
      }
      *write++ = '<';
      *write = '\0';
      strcat(write, fptr);
      debug_message("before chomp \"%s\"", m_encodedFrame);
      chomp();
      strcat(write, ">");
      debug_message("\"%s\"", m_encodedFrame);
    }
    m_encodedFrameLen = strlen(m_encodedFrame) + 1;
    return true;
  };
Beispiel #5
0
static void on_drag_data_received_entry (GtkWidget *widget,
        GdkDragContext *context,
        gint x,
        gint y,
        GtkSelectionData *selection_data,
        guint info,
        guint time)
{

    gchar *temp, *string;

    string = (gchar *)selection_data->data;
    ADV_SPACE(string);
    temp = string + strlen(string) - 1;
    while (isspace(*temp)) {
        *temp = '\0';
        temp--;
    }

    gtk_entry_set_text(GTK_ENTRY(widget), string);
}
Beispiel #6
0
/*
 * Decode task call for FAAC
 */
static int href_decode (codec_data_t *cptr,
                        frame_timestamp_t *pts,
                        int from_rtp,
                        int *sync_frame,
                        uint8_t *buffer,
                        uint32_t buflen,
                        void *ud)
{
    href_codec_t *href = (href_codec_t *)cptr;
    uint32_t orig_buflen = buflen;
    uint64_t ts = pts->msec_timestamp;

    if (ud != NULL) {
        const char *base_url = (const char *)ud;
        if (href->m_base_url == NULL ||
                strcmp(href->m_base_url, base_url) != 0) {
            href->m_base_url = strdup(base_url);
        }
        free(ud);
    }
    //LOGIT(LOG_DEBUG, "hrefd", "buffer %s", buffer);
    // use href_display_structure_t to pass the
#ifdef DEBUG_HREF
    LOGIT(LOG_DEBUG, "href_plug", "href %s at "U64,
          buffer, ts);
#endif
    href_display_structure_t display;
    memset(&display, 0, sizeof(display));
    if (buflen + 1 > href->m_buffer_len) {
        href->m_buffer = (char *)realloc(href->m_buffer, buflen + 1);
    }
    memcpy(href->m_buffer, buffer, buflen);
    href->m_buffer[buflen] = '\0'; // at end, so we can do string things.

    char *ptr = href->m_buffer;
    if (*ptr == 'A') {
        display.auto_dispatch = true;
        ptr++;
    }

    ADV_SPACE(ptr);
    if (*ptr != '<') {
        LOGIT(LOG_INFO, "href", "Illegal first element in \"%s\"", href->m_buffer);
        return orig_buflen;
    }
    ptr++;
    display.url = ptr;
    while (*ptr != '>' && *ptr != '\0') ptr++;
    if (*ptr != '>') {
        LOGIT(LOG_INFO, "href", "Can't find end of element in \"%s\"",
              href->m_buffer);
        return orig_buflen;
    }
    *ptr = '\0';
    if (href->m_base_url != NULL) {
        const char *slash = strchr(display.url, '/');
        const char *colon = strchr(display.url, ':');
        if (slash == NULL || colon == NULL || colon > slash) {
            // need to add base url
            CHECK_AND_FREE(href->m_url);
            href->m_url = (char *)malloc(strlen(href->m_base_url) + strlen(display.url) + 1);
            strcpy(href->m_url, href->m_base_url);
            strcat(href->m_url, display.url);
            display.url = href->m_url;
        }
    }
    ptr++;
    while (*ptr != '\0') {
        char *val = ptr, *start;
        ptr++;
        ADV_SPACE(ptr);
        if (*ptr != '<') {
            LOGIT(LOG_INFO, "href", "Can't find start of element \"%s\"",
                  val);
            return orig_buflen;
        }
        ptr++;
        start = ptr;
        while (*ptr != '>' && *ptr != '\0') ptr++;
        if (*ptr != '>') {
            LOGIT(LOG_INFO, "href", "Can't find end of element in \"%s\"", val);
            return orig_buflen;
        }
        *ptr = '\0';
        ptr++;
        switch (tolower(*val)) {
        case 't':
            if (display.target_element != NULL) {
                LOGIT(LOG_INFO, "href", "duplicate target element in href");
                return orig_buflen;
            }
            display.target_element = start;
            break;
        case 'e':
            if (display.embed_element != NULL) {
                LOGIT(LOG_INFO, "href", "duplicate embed element in href");
                return orig_buflen;
            }
            display.embed_element = start;
            break;

        case 'm':
            display.send_click_location = true;
            break;
        }
    }
    // do rest of parsing.
    (href->m_vft->text_have_frame)(href->m_ifptr,
                                   ts,
                                   TEXT_DISPLAY_TYPE_HREF,
                                   &display);

    return (orig_buflen);
}
int parse_name_for_session (CPlayerSession *psptr,
                            const char *name,
                            char *errmsg,
                            uint32_t errlen,
                            control_callback_vft_t *cc_vft)
{
    int err;
#ifdef HAVE_IGMP_V3
    //  gross, but here for multiple files
    const char *mcast_src = config.get_config_string(CONFIG_MULTICAST_SRC);
    if (mcast_src != NULL) {
        udp_set_multicast_src(mcast_src);
    } else {
        udp_set_multicast_src("0.0.0.0");
    }
#endif

    ADV_SPACE(name);
    if (strncmp(name, "rtsp://", strlen("rtsp://")) == 0) {
        err = create_media_for_streaming_ondemand(psptr,
                name,
                errmsg,
                errlen,
                cc_vft);
        return (err);
    }
    if (strncmp(name, "http://", strlen("http://")) == 0) {
        err = create_media_for_http(psptr, name, errmsg, errlen, cc_vft);
        return (err);
    }

    int have_audio_driver;

    have_audio_driver = do_we_have_audio();
#ifndef _WIN32
    if (strncmp(name, "iptv://", strlen("iptv://")) == 0) {
        err = create_media_for_iptv(psptr,
                                    name,
                                    errmsg,
                                    errlen,
                                    have_audio_driver,
                                    cc_vft);
        return err;
    }
#endif
#ifndef _WIN32
    if (strncmp(name, "mpeg2t://", strlen("mpeg2t://")) == 0) {
        err = create_mpeg2t_session(psptr, name, NULL, errmsg, errlen,
                                    have_audio_driver, cc_vft);
        return (err);
    }

    struct stat statbuf;
    if (stat(name, &statbuf) != 0) {
        snprintf(errmsg, errlen, "File \'%s\' not found", name);
        return (-1);
    }
    if (!S_ISREG(statbuf.st_mode)) {
        snprintf(errmsg, errlen, "File \'%s\' is not a file", name);
        return (-1);
    }
#else
    OFSTRUCT ReOpenBuff;
    if (OpenFile(name, &ReOpenBuff,OF_READ) == HFILE_ERROR) {
        snprintf(errmsg, errlen, "File %s not found", name);
        return (-1);
    }

#endif
    err = -1;

    const char *suffix = strrchr(name, '.');
    if (suffix == NULL) {
        snprintf(errmsg, errlen, "No useable suffix on file %s", name);
        return err;
    }


    if (strcasecmp(suffix, ".sdp") == 0) {
        err = create_media_from_sdp_file(psptr,
                                         name,
                                         errmsg,
                                         errlen,
                                         have_audio_driver,
                                         cc_vft);
    } else if ((strcasecmp(suffix, ".mov") == 0) ||
               (strcasecmp(suffix, ".mp4") == 0) ||
               (strcasecmp(suffix, ".3gp") == 0) ||
               (strcasecmp(suffix, ".m4a") == 0)) {
        if (config.get_config_value(CONFIG_USE_OLD_MP4_LIB) == 0) {
            err = create_media_for_mp4_file(psptr,
                                            name,
                                            errmsg,
                                            errlen,
                                            have_audio_driver,
                                            cc_vft);
        } else err = -1;
        if (err < 0) {
            err = create_media_for_qtime_file(psptr,
                                              name,
                                              errmsg,
                                              errlen,
                                              have_audio_driver);
        }
    } else if (strcasecmp(suffix, ".avi") == 0) {
        err = create_media_for_avi_file(psptr,
                                        name,
                                        errmsg,
                                        errlen,
                                        have_audio_driver,
                                        cc_vft);
    } else if (strcasecmp(suffix, ".mpeg") == 0 ||
               strcasecmp(suffix, ".mpg") == 0 ||
               strcasecmp(suffix, ".vob") == 0) {
#ifdef _WIN32
        err = -1;
#else
        err = create_media_for_mpeg2t_file(psptr, name, errmsg, errlen,
                                           have_audio_driver, cc_vft);

        if (err < 0) {
            err = create_media_for_mpeg_file(psptr, name, errmsg,
                                             errlen, have_audio_driver, cc_vft);
        }
#endif
    } else {
        // raw files
        codec_data_t *cdata = NULL;
        double maxtime;
        char *desc[4];
        bool is_video = false;
        codec_plugin_t *codec;
        desc[0] = NULL;
        desc[1] = NULL;
        desc[2] = NULL;
        desc[3] = NULL;

        if (have_audio_driver) {
            cdata = audio_codec_check_for_raw_file(name,
                                                   &codec,
                                                   &maxtime,
                                                   desc,
                                                   &config);
        }
        if (cdata == NULL) {
            cdata = video_codec_check_for_raw_file(name,
                                                   &codec,
                                                   &maxtime,
                                                   desc,
                                                   &config);
            is_video = true;
        }

        if (cdata == NULL) {
            err = -1;
        } else {
            CPlayerMedia *mptr;
            /*
             * Create the player media, and the bytestream
             */
            mptr = new CPlayerMedia(psptr);

            COurInByteStreamFile *fbyte;
            fbyte = new COurInByteStreamFile(codec,
                                             cdata,
                                             maxtime);
            mptr->create(fbyte, is_video);
            mptr->set_plugin_data(codec, cdata,
                                  is_video ? get_video_vft() : NULL,
                                  is_video ? NULL : get_audio_vft());

            for (int ix = 0; ix < 4; ix++)
                if (desc[ix] != NULL)
                    psptr->set_session_desc(ix, desc[ix]);

            if (maxtime != 0.0) {
                psptr->session_set_seekable(1);
            }
            err = 0;
        }
    }

    if (err >= 0) {
        const char *temp;
        temp = psptr->get_session_desc(0);
        if (temp == NULL) {
            psptr->set_session_desc(0, name);
        }
    }
    return (err);
}