コード例 #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
ファイル: ap_mms_plugin.cpp プロジェクト: sophom/gogglesmm
FXbool MMSInput::open(const FXString & uri) {
  mms=mms_connect(NULL,NULL,uri.text(),128*1024);
  if (!mms) {
    GM_DEBUG_PRINT("failed to connect\n");
    return false;
    }
  GM_DEBUG_PRINT("mms connected\n");
  return true;
  }
コード例 #3
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;
  }
}
コード例 #4
0
ファイル: mmsx.c プロジェクト: fcgll520/testmmsdump
mmsx_t *mmsx_connect(mms_io_t *io, void *data, const char *url, int bandwidth)
{
  mmsx_t *mmsx = calloc(1, sizeof(mmsx_t));
  
  if (!mmsx)
    return mmsx;
    
  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;

  free(mmsx);
  return NULL;
}
コード例 #5
0
ファイル: mms.c プロジェクト: rapidrabbit/audacious-plugins
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;
}
コード例 #6
0
ファイル: htsmms.c プロジェクト: eatonmi/Crawler
/* Code mainly written by Nicolas BENOIT */
static int run_launch_mms(MMSDownloadStruct* pStruct) {
	lien_back* back = pStruct->pBack;
	httrackp* opt = pStruct->pOpt;
	/* */
	char url[HTS_URLMAXSIZE*2];
	char catbuff[CATBUFF_SIZE];
	char catbuff2[CATBUFF_SIZE];
  MMS *mms;
  FILE *f;
  ssize_t len_written;
	uint64_t total_len_written;
	int delay = opt->mms_maxtime;
	time_t end = time(NULL) + delay;
	short checkPending = 0;
	ssize_t existingSize = fsize(back->url_sav);

	// effacer
	strcpybuff(back->r.msg,"");
	back->status=STATUS_FTP_TRANSFER;
	back->r.statuscode=HTTP_OK;
	back->r.size=0;

	/* Create file */
	if (existingSize > 0) {
		/* back->r.out = fileappend(back->url_sav);
		*/
		(void) unlink(fconcat(catbuff,back->url_sav, ".old"));
		if (rename(fconcat(catbuff,back->url_sav, ""), fconcat(catbuff2,back->url_sav, ".old")) == 0) {
			checkPending = 1;
		}
		back->r.out = filecreate(&pStruct->pOpt->state.strc, back->url_sav);
	} else {
		back->r.out = filecreate(&pStruct->pOpt->state.strc, back->url_sav);
	}
	if ((f = back->r.out) != NULL) {
		// create mms resource
		strcpybuff(url, back->url_adr);				/* mms:// */
		strcatbuff(url, back->url_fil);
		if ( ( mms = mms_create( url, f, NULL, 0, 1 ) ) != NULL ) {
			if ( mms_connect ( mms ) == 0 ) {
				if ( mms_handshake ( mms ) == 0 ) {
					if ( ( len_written = mms_write_stream_header ( mms ) ) != -1 ) {
						total_len_written = len_written;
						HTS_STAT.HTS_TOTAL_RECV += len_written;

						/* not modified */
						if (checkPending) {
							if (mms->is_live != MMS_LIVE
								&& mms->expected_file_size == existingSize + 50	/* Why 50 additional bytes declared ?? */
								)				// abort download
							{
								fclose(back->r.out);
								f = back->r.out = NULL;
								if (unlink(fconcat(catbuff, back->url_sav, "")) == 0 
									&& rename(fconcat(catbuff, back->url_sav, ".old"), fconcat(catbuff2, back->url_sav, "")) == 0) 
								{
									back->r.notmodified = 1;
									back->r.statuscode = HTTP_OK;
									strcpybuff(back->r.msg, "Not modified");
								} else {
									back->r.statuscode = HTTP_INTERNAL_SERVER_ERROR;
									strcpybuff(back->r.msg, "Unable to rename previous file (not updated)");
								}
							} else {
								(void) unlink(fconcat(catbuff, back->url_sav, ".old"));
							}
						}

						/* begin rip */
						if ( f != NULL && mms_begin_rip ( mms ) == 0 ) {
							if ( mms->is_live != MMS_LIVE ) {
								back->r.totalsize = mms->expected_file_size;
								back->r.totalsize -= 50;	/* Why 50 additional bytes declared ?? */
							} else
								back->r.totalsize = -1;

							/* Start download */
							while ( !stop_mms(back) ) {
								len_written = mms_write_stream_data ( mms );
								if ( len_written == 0 ) {
									break;
								} else if ( len_written == -1 ) {
									back->r.statuscode = HTTP_INTERNAL_SERVER_ERROR;
									strcpybuff(back->r.msg, "Unable to write stream data");
									break;
								}

								total_len_written += len_written;
								back->r.size = total_len_written;
								HTS_STAT.HTS_TOTAL_RECV += len_written;

								fflush ( f );

								if ( delay != 0 && end <= time(NULL) ) {
									delay = -1;
									back->r.statuscode = HTTP_OK;
									strcpybuff(back->r.msg, "Download interrupted");
									break;
								}
							}		// while

							back->r.statuscode = HTTP_OK;			/* Finished */
						} else if (f != NULL) {
							back->r.statuscode = HTTP_INTERNAL_SERVER_ERROR;
							strcpybuff(back->r.msg, "Can not begin ripping");
						}
					} else {
						back->r.statuscode = HTTP_INTERNAL_SERVER_ERROR;
						strcpybuff(back->r.msg, "Can not write stream header");
					}
				} else {
					back->r.statuscode = HTTP_INTERNAL_SERVER_ERROR;
					strcpybuff(back->r.msg, "Can not handshake");
				}
				mms_disconnect ( mms );
			} else {
				back->r.statuscode = HTTP_INTERNAL_SERVER_ERROR;
				strcpybuff(back->r.msg, "Can not connect");
			}
			mms_destroy ( mms );
		} else {
			back->r.statuscode = HTTP_INTERNAL_SERVER_ERROR;
			strcpybuff(back->r.msg, "Can not create mms resource");
		}
	} else {
		back->r.statuscode = HTTP_INTERNAL_SERVER_ERROR;
		strcpybuff(back->r.msg, "Unable to open local output file");
	}
	return 0;
}