سؤال

Trying to build Xuggler under Windows. Xuggler is core native code functions wrapped into Java for sound processing purposes (including ffmpeg).

My Windows is x64 Win 7 prof, but all used libraries are 32bit. I am running build procedure under MinGW/MSys, from under Msys shell with the followinf script:

#!/bin/sh
export JAVA_HOME=/C/Program\ Files\ \(x86\)/Java/jdk1.6.0_25
export XUGGLE_HOME=/C/Xuggler

PATH=$XUGGLE_HOME/bin:/C/Program\ Files\ \(x86\)/Java/jdk1.6.0_25/bin:/d/APPS/msysgit/msysgit/bin/git:/D/APPS/MinGW/bin:/bin:/D/APPS/apa    che-ant-1.8.2/bin:/D/Users/Dims/Design/MinGW/Util:$PATH
ant -Dbuild.m64=no run-tests

Ant target contains some tests at the end, which give an error. The error follows

 [exec] Running 6 tests..
 [exec] In StdioURLProtocolHandlerTest::testRead:
 [exec] ../../../../../../../../../test/csrc/com/xuggle/xuggler/io/StdioURLProtocolHandlerTest.cpp:108: Error: Expected (4546420 == totalBytes), found (4546420 != 1042)
 [exec] In StdioURLProtocolHandlerTest::testReadWrite:
 [exec] ../../../../../../../../../test/csrc/com/xuggle/xuggler/io/StdioURLProtocolHandlerTest.cpp:185: Error: Expected (4546420 == totalBytes), found (4546420 != 1042)
 [exec] In StdioURLProtocolHandlerTest::testSeek:
 [exec] ../../../../../../../../../test/csrc/com/xuggle/xuggler/io/StdioURLProtocolHandlerTest.cpp:139: Error: Expected (4546420 == totalBytes), found (4546420 != 1042)
 [exec] .
 [exec] Failed 3 of 6 tests
 [exec] Success rate: 50%
 [exec] FAIL: xugglerioTestStdioURLProtocolHandler.exe

UPDATE 1

The test code is follows:

int32_t totalBytes = 0;
do {
    unsigned char buf[2048];
    retval = handler->url_read(buf, (int)sizeof(buf));
    if (retval > 0)
         totalBytes+= retval;
} while (retval > 0);
VS_TUT_ENSURE_EQUALS("", 4546420, totalBytes);

While the url_read code is follows:

int
StdioURLProtocolHandler :: url_read(unsigned char* buf, int size)
{
    if (!mFile)
        return -1;
    return (int) fread(buf, 1, size, mFile);
}

I don't understand, under what circumstances it can return 1042??? May be 64 bits play here somehow?

UPDATE 2

I printed out filename used and it was

d:/......./../../../test/fixtures/testfile.flv

the path is correct, but started with d:/ not with /d/

Can this play a role under Msys?

UPDATE 3

I have compared the readen bytes with real content of the test file and found, that fread() skips some bytes for some reason. Don't know which bytes yet, probably these are CR/LF

UPDATE 4

Not related with CR/LF I guess.

Original bytes are

46 4C 56 01 05 00 00 00 09 00 00 00 00 12 00 00 F4 00 00 00 00 00 00 00 02 00 0A 6F 6E 4D 65 74 61 44 61 74 61 08 00 00 ...

readen bytes are

46 4C 56 15 00 09 00 00 12 00 F4 00 00 00 02 0A 6F 6E 4D 65 74 61 44 61 74 61 80 00 B0 86 47 57 26 17 46 96 F6 E0 40 62 ...

This is FLV file begin. I don't understand the ptinciple of corruption.

How can 01 05 00 00 transform to just 15???

UPDATE 5

File opening done like following

void
StdioURLProtocolHandlerTest :: testRead()
{
  StdioURLProtocolManager::registerProtocol("test");
  URLProtocolHandler* handler = StdioURLProtocolManager::findHandler("test:foo", 0,0);
  VS_TUT_ENSURE("", handler);

  int retval = 0;
  retval = handler->url_open(mSampleFile, URLProtocolHandler::URL_RDONLY_MODE);
  VS_TUT_ENSURE("", retval >= 0);

  int32_t totalBytes = 0;
  printf("Bytes:\n");
  do {
     //...

url_open() function follows:

int StdioURLProtocolHandler :: url_open(const char *url, int flags)
{
  if (!url || !*url)
    return -1;
  reset();
  const char * mode;

  switch(flags) {
    case URLProtocolHandler::URL_RDONLY_MODE:
      mode="r";
      break;
    case URLProtocolHandler::URL_WRONLY_MODE:
      mode="w";
      break;
    case URLProtocolHandler::URL_RDWR_MODE:
          mode="r+";
          break;
        default:
      return -1;
  }

  // The URL MAY contain a protocol string.  Find it now.
  char proto[256];
  const char* protocol = URLProtocolManager::parseProtocol(proto, sizeof(proto), url);
  if (protocol)
  {
    size_t protoLen = strlen(protocol);
    // skip past it
    url = url + protoLen;
    if (*url == ':' || *url == ',')
      ++url;
  }
//  fprintf(stderr, "protocol: %s; url: %s; mode: %s\n", protocol, url, mode);
  mFile = fopen(url, mode);
  if (!mFile)
    return -1;
  return 0;
}
هل كانت مفيدة؟

المحلول

Should be fixed in the GIT repository on the cross_compile branch as of today. I will roll this into tip of tree later this week / early next week.

Now the stdio handler opens all files as binary.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top