我是否正确使用GMFBridge. dll和GMFBridge播放器,GMFBridge播放器是否可以从套接字获取数据

Am i using the GMFBridge.DLL and GMFBridge player correctly and can gmf player be made to take data from socket?

本文关键字:GMFBridge 播放器 是否 套接字 数据 获取 dll      更新时间:2023-10-16

我需要一个应用程序,我想把NAL单位的字节流给GMFBridge播放器而不是文件。所以我做了下面的事情为演示获取该文件并解析该文件,以便我可以找到最后的单元

   FILE* infile;
    uint8_t* buf = (uint8_t*)malloc(BUFSIZE );
    char* buf1 = new char(BUFSIZE );
    h264_stream_t* h = h264_new();
    /*if (argc < 2) { usage(); return EXIT_FAILURE; }*/
     infile = fopen(Filepath, "rb");
   while (1)
    {
        rsz = fread(buf + sz, 1, BUFSIZE - sz, infile);
    fseek (infile , 0 , SEEK_END);
   lSize = ftell (infile);
   rewind (infile);
   buffer = (char*) malloc (sizeof(char)*lSize);
  if (buffer == NULL)
  {fputs ("Memory error",stderr); exit (2);}
  // copy the file into the buffer:
  result = fread (buffer,1,lSize,infile);
  if (result != lSize) 
  {fputs ("Reading error",stderr); exit (3);}
   fprintf( h264_dbgfile1,"data in file is %lldn",buffer);
   int l=strlen(buffer);
      fclose (h264_dbgfile1);
  if (rsz == 0)
        {
            if (ferror(infile)) { fprintf( stderr, "!! Error: read failed: %s n", strerror(errno)); break; }
            break;  // if (feof(infile)) 
        }
        sz += rsz;
        while (find_nal_unit(p, sz, &nal_start, &nal_end) > 0)
{
                   int length =nal_end-nal_start;
            int j=0;
            while(length!=0)
            {
            for (int start=nal_start;start<=nal_end;start++)
            {
                             FileData[pointer][j]=buffer[start];
                //FileData[pointer][j]=(p[j]);
                j++;
                length--;
                if(length==0)
                    break;
            }
            }
HRESULT hr = m_pPlayer->AddClip(ofn.lpstrFile, &pClip);//i am not able to give the data here

请告诉上面的解决方案,或者我们可以连接GMFBridge播放器从socket获取数据并连续播放。我尝试使用套接字,但没有收到数据,因为连接调用成功

int find_nal_unit(uint8_t* buf, int size, int* nal_start, int* nal_end)
{
    int i;
    // find start
    *nal_start = 0;
    *nal_end = 0;
    i = 0;
    while (   //( next_bits( 24 ) != 0x000001 && next_bits( 32 ) != 0x00000001 )
        (buf[i] != 0 || buf[i+1] != 0 || buf[i+2] != 0x01) && 
        (buf[i] != 0 || buf[i+1] != 0 || buf[i+2] != 0 || buf[i+3] != 0x01) 
        )
    {
        i++; // skip leading zero
        if (i+4 >= size) { return 0; } // did not find nal start
    }
    if  (buf[i] != 0 || buf[i+1] != 0 || buf[i+2] != 0x01) // ( next_bits( 24 ) != 0x000001 )
    {
        i++;
    }
    if  (buf[i] != 0 || buf[i+1] != 0 || buf[i+2] != 0x01) { /* error, should never happen */ return 0; }
    i+= 3;
    *nal_start = i;
    while (   //( next_bits( 24 ) != 0x000000 && next_bits( 24 ) != 0x000001 )
        (buf[i] != 0 || buf[i+1] != 0 || buf[i+2] != 0) && 
        (buf[i] != 0 || buf[i+1] != 0 || buf[i+2] != 0x01) 
        )
    {
        i++;
        // FIXME the next line fails when reading a nal that ends exactly at the end of the data
        if (i+3 >= size) { *nal_end = size; return -1; } // did not find nal end, stream ended first
    }
    *nal_end = i;
    return (*nal_end - *nal_start);
}

Bridge连接两个图,这样您就可以独立地更改它们的状态,而不会出现不必要的流中断。它与H.264、Sockets和NAL单位无关。

如果你发现或创建了一个过滤器,它可以将从套接字接收到的有效载荷传递到DirectShow管道中,桥将能够接受它并传递到第二个图中