0

下面我编写了示例代码来下载前 7 块单一质量的 mpd 文件以及该特定质量的基本 url mp4。我将 m4s 块放入字符串队列中。我如何播放下载的数据。我有队列,在第一次迭代中是特定质量的 mp4 段,然后在随后的迭代中,我有相同质量的 m4s 块现在我想使用 ffmpeg 或 gstreamer 播放这个队列缓冲区。我怎么能单独做到这一点我能够播放通过下载单个 mp4(在 mpd 结构中具有特定质量)然后使用 cat 与 m4s 块连接然后播放。

如果有人有任何想法,在开源 libdash 中它是如何完成的。

请指导。

  #include <iostream>
#include <string.h>
#include <curl/curl.h> 
#include <queue>
#include <cstdlib>

using namespace std;
string data; 
std::queue<string> myqueue;
int size =0;



 size_t writeCallback(char* buf, size_t size, size_t nmemb, void* up)
 { 

  printf("size  = %d\n\n\n",size);
  printf("size nmemb  = %d\n\n\n\n\n",nmemb);
  for (int c = 0; c<size*nmemb; c++)
  {
    data.push_back(buf[c]);
  }

  myqueue.push (data);  
   return size*nmemb; //tell curl how many bytes we handled
  }



  int main()
  {
  CURL* curl; //our curl object
  char url_firstpart[80];// = NULL;
  char bitwide_chunk[10];
  char buffer[10];


curl_global_init(CURL_GLOBAL_ALL); //pretty obvious
curl = curl_easy_init();

for(int i=0;i<7;i++)
{   

strcpy(url_firstpart,"http://www-itec.uni- klu.ac.at/ftp/datasets/mmsys12/Valkaama/valkaama_1s/valkaama_1s_50kbit/valkaama_1s");
string str = to_string(i);

char * writable = new char[str.size() + 1];
std::copy(str.begin(), str.end(), writable);
writable[str.size()] = '\0'; 

strcat(writable,".m4s"); 
printf("concanated chink is %s\n",writable);

strcat(url_firstpart,bitwide_chunk);
puts(url_firstpart);


curl_easy_setopt(curl, CURLOPT_URL,url_firstpart);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &writeCallback);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); 

curl_easy_perform(curl);



}

size = myqueue.size();
printf("Final size of queue = %d\n",size);
cout << endl << data << endl;
  cin.get();

  curl_easy_cleanup(curl);
  curl_global_cleanup();

  return 0;
 }
4

0 回答 0