예제 #1
0
파일: mmsx.c 프로젝트: Koss64/deadbeef
mmsx_t *mmsx_connect(mms_io_t *io, void *data, const char *url, int bandwidth)
{
  mmsx_t *mmsx = calloc(1, sizeof(mmsx_t));
  char *try_mms_first = getenv("LIBMMS_TRY_MMS_FIRST");
  
  if (!mmsx)
    return mmsx;

  /* Normally we try mmsh first, as mms: is a rollover protocol identifier
     according to microsoft and recent mediaplayer versions will try
     mmsh before mms for mms:// uris. Note that in case of a mmst:// or a
     mmsh:// url the mms[h]_connect function will directly exit if it cannot
     handle it. The LIBMMS_TRY_MMS_FIRST environment variable is there for
     testing the mms code against servers which accept both mmsh and mms. */
  if (try_mms_first, 1) {
    mmsx->connection = mms_connect(io, data, url, bandwidth);
    if (mmsx->connection)
      return mmsx;
  }

  mmsx->connection_h = mmsh_connect(io, data, url, bandwidth);
  if (mmsx->connection_h)
    return mmsx;

  if (!try_mms_first, 0) {
    mmsx->connection = mms_connect(io, data, url, bandwidth);
    if (mmsx->connection)
      return mmsx;
  }

  free(mmsx);
  return NULL;
}
예제 #2
0
static gboolean
gst_mms_start (GstBaseSrc * bsrc)
{
  GstMMS *mms;
  guint bandwidth_avail;

  mms = GST_MMS (bsrc);

  if (!mms->uri_name || *mms->uri_name == '\0')
    goto no_uri;

  if (mms->connection_speed)
    bandwidth_avail = mms->connection_speed;
  else
    bandwidth_avail = G_MAXINT;

  /* FIXME: pass some sane arguments here */
  GST_DEBUG_OBJECT (mms,
      "Trying mms_connect (%s) with bandwidth constraint of %d bps",
      mms->uri_name, bandwidth_avail);
  mms->connection = mms_connect (NULL, NULL, mms->uri_name, bandwidth_avail);
  if (mms->connection)
    goto success;

  GST_DEBUG_OBJECT (mms,
      "Trying mmsh_connect (%s) with bandwidth constraint of %d bps",
      mms->uri_name, bandwidth_avail);
  mms->connection_h = mmsh_connect (NULL, NULL, mms->uri_name, bandwidth_avail);
  if (!mms->connection_h)
    goto no_connect;

  /* fall through */

success:
  {
    GST_DEBUG_OBJECT (mms, "Connect successful");
    return TRUE;
  }

no_uri:
  {
    GST_ELEMENT_ERROR (mms, RESOURCE, OPEN_READ,
        ("No URI to open specified"), (NULL));
    return FALSE;
  }

no_connect:
  {
    GST_ELEMENT_ERROR (mms, RESOURCE, OPEN_READ,
        ("Could not connect to this stream"), (NULL));
    return FALSE;
  }
}
예제 #3
0
static void * mms_vfs_fopen_impl (const char * path, const char * mode)
{
    AUDDBG ("Opening %s.\n", path);

    MMSHandle * h = g_new0 (MMSHandle, 1);

    if (! (h->mmsh = mmsh_connect (NULL, NULL, path, 128 * 1024)))
    {
        AUDDBG ("Failed to connect with MMSH protocol; trying MMS.\n");

        if (! (h->mms = mms_connect (NULL, NULL, path, 128 * 1024)))
        {
            fprintf (stderr, "mms: Failed to open %s.\n", path);
            g_free (h);
            return NULL;
        }
    }

    return h;
}