freeMXF.org

Open discussion about freeMXF.org tools and MXF in general
It is currently Thu Mar 28, 2024 11:27 pm
Board index » MXF Categories » freeMXF.org Tools



Post new topic Reply to topic  [ 11 posts ] 
Author
Search for:
Message

Offline
Board User

Joined: Tue Mar 09, 2010 12:30 pm
Posts: 8
Location: Poland, Poznan

Post Posted: Fri Mar 26, 2010 3:39 pm 
Top  
Hello everyone,
I need a help. In fact, I beg you for helping me.
I spent all week trying to read data from file with bodyReaderPtr->ReadFromFile() function but it doesn't work.
I have to get JPEG2000 files from MXF file.
Could you help me, please?
I presented my code below. Maybe should I do it in another way?


I built mainProcess function:
Code:
int MXFManager ::mainProcess() {
   MyGCReadHandler* myGCReadHandlerPtr = new MyGCReadHandler();
   BodyReaderPtr bodyReaderPtr = new BodyReader(inFilePtr);
   
   for( ;  ; ) {      // till readResult breaks the loop
      UInt32 bodySID = bodyReaderPtr->GetBodySID();
      cout << "bodySID: " << bodySID << endl;
      cout << "MakeGCReader(bodySID): " << bodyReaderPtr->MakeGCReader(bodySID) << endl;
      GCReaderPtr gcReaderPtr = bodyReaderPtr->GetGCReader(bodySID);
      gcReaderPtr->SetDataHandler(bodySID);
      cout << "Tell(): " << bodyReaderPtr->Tell() << endl;
      inFilePtr->Seek(bodyReaderPtr->Tell());
      bool readResult= bodyReaderPtr->ReadFromFile();      // CRASH!!!
      cout << "readResult: " << readResult << endl;
      if (!readResult) {
         break;
      }
      bodyReaderPtr->ReSync();
   }
   return 0;
}


My HandleData is shown below.
Code:

// class MyGCReadHandler : GCReadHandler_Base

bool MyGCReadHandler ::HandleData(mxflib::GCReaderPtr Caller, mxflib::KLVObjectPtr Object){
   cout << "MyGCReadHandler ::HandleData" << endl ;
   return true;
}


Problems.

1. Program is crashed in line with:
bool readResult= gcReaderPtr->ReadFromFile();

2. I've read Ly's posts
http://www.freemxf.org/freemxf_board/vi ... 8420633da0

I tried to do it the same he does. I called:
gcReaderPtr->SetDataHandler(bodySID,myGCReadHandlerPtr);
but compiler returns: "error C2243: 'type cast' : conversion from 'MyGCReadHandler *' to 'mxflib::IRefCount<T> *' exists, but is inaccessible".
So I call

3. I've read Matt's chapter in the MXF Book. I don't understand something.
On page 328 there are two examples with two for_each loops.
Code:
BodyReaderPtr BodyParser = new BodyReader(InFile);
for_each(BodySID) {
   BodyParser->MakeGCReader(BodySID, DefaultHandler[BodySID]);
   GCReaderPtr ThisReader = BodyParser->GetGCReader(BodySID);
   for_each(TrackNumber in BodySID) {
      ThisReader->SetDataHandler(TrackNumber, Handler[BodySID][TrackNumber]);
   }
}

- "TrackNumber in BodySID" - I don't understand it. BodySID is UInt32 not table or list, isn't it? How to get BodySID and TrackNumber?
- How should I create DefaultHandler and Handler tables?


I don't know what it's wrong.
I'll be really grateful for explain me it.
Bernard

 Profile  

Offline
Insider

Joined: Thu Apr 15, 2004 10:39 am
Posts: 198
Location: Scotland

Post Posted: Tue Mar 30, 2010 8:50 am 
Top  
A few questions:

1) Why are you doing this?
Code:
inFilePtr->Seek(bodyReaderPtr->Tell());


2) The following line removes the data handler allocated to bodySID - is this what you intend?
Code:
gcReaderPtr->SetDataHandler(bodySID);


3) What do you mean by "CRASH!!!"

4) When you define class MyGCReadHandler, is it defined with a "public" base class of "GCReadHandler_Base", or private?

 Profile WWW  

Offline
Board User

Joined: Tue Mar 09, 2010 12:30 pm
Posts: 8
Location: Poland, Poznan

Post Posted: Tue Mar 30, 2010 1:08 pm 
Top  
1) I tried to running my program, but I couldn't find where I made a mistake (or mistakes).
I added the line with seek() function, because I thought it's needed to start from beginning of an MXF file.

2) Removes? I thought I have to set the handler to get an access to the file. On page 328 of the MXF book there are loops with SetDataHandler() so I thought I have add this line.

3) By "CRASH!!!" I mean that the program breaks in this line. Debugger returns:
Debug Assertion Failed!
(path) \mxflib\smartptr.h
Line: 470

4) It's defind with private operator.

 Profile  

Offline
Insider

Joined: Thu Apr 15, 2004 10:39 am
Posts: 198
Location: Scotland

Post Posted: Thu Apr 01, 2010 8:13 am 
Top  
So, it seems that the "private" class derivation is the problem.

If you define it as "public" you should be able to add that then with a SetDataHandler() call.

 Profile WWW  

Offline
Board User

Joined: Tue Mar 09, 2010 12:30 pm
Posts: 8
Location: Poland, Poznan

Post Posted: Tue Apr 06, 2010 12:03 pm 
Top  
I changed from private to public:
Code:
class MyGCReadHandler : public GCReadHandler_Base {
public:
   MyGCReadHandler();
   bool HandleData(GCReaderPtr Caller, KLVObjectPtr Object);
};


but it still doesn't work.
The same error appears:

Debug Assertion Failed!
(path) \mxflib\smartptr.h
Line: 470

 Profile  

Offline
Insider

Joined: Thu Apr 15, 2004 10:39 am
Posts: 198
Location: Scotland

Post Posted: Wed Apr 07, 2010 11:01 am 
Top  
Have you now set the correct data handler?

What is the point in you code that triggers the assert?

 Profile WWW  

Offline
Board User

Joined: Tue Mar 09, 2010 12:30 pm
Posts: 8
Location: Poland, Poznan

Post Posted: Wed Apr 07, 2010 12:55 pm 
Top  
Yes, I set data handler:

Code:
MyGCReadHandler* myGCReadHandlerPtr = new MyGCReadHandler();
gcReaderPtr->SetDataHandler(bodySID, myGCReadHandlerPtr);


I'd like to read an mxf file and then get jpeg2000 files from it.

Maybe I should do it in another way?

 Profile  

Offline
Insider

Joined: Thu Apr 15, 2004 10:39 am
Posts: 198
Location: Scotland

Post Posted: Thu Apr 08, 2010 9:07 am 
Top  
Not sure what is causing your problem. When I run the following code:
Code:
class MyGCReadHandler : public GCReadHandler_Base
{
    bool HandleData(mxflib::GCReaderPtr Caller, mxflib::KLVObjectPtr Object){
        cout << "MyGCReadHandler ::HandleData" << endl ;
        return true;
    };
};

int main(int argc, char *argv[])
{
   LoadDictionary("dict.xml");

   MXFFilePtr inFilePtr = new MXFFile();
   inFilePtr->Open("test.mxf");

   MyGCReadHandler* myGCReadHandlerPtr = new MyGCReadHandler();
   BodyReaderPtr bodyReaderPtr = new BodyReader(inFilePtr);
   
   for( ;  ; ) {      // till readResult breaks the loop
      UInt32 bodySID = bodyReaderPtr->GetBodySID();
      cout << "bodySID: " << bodySID << endl;
      cout << "MakeGCReader(bodySID): " << bodyReaderPtr->MakeGCReader(bodySID) << endl;
      GCReaderPtr gcReaderPtr = bodyReaderPtr->GetGCReader(bodySID);
      gcReaderPtr->SetDataHandler(bodySID);
      cout << "Tell(): " << bodyReaderPtr->Tell() << endl;
      inFilePtr->Seek(bodyReaderPtr->Tell());
      bool readResult= bodyReaderPtr->ReadFromFile();
      cout << "readResult: " << readResult << endl;
      if (!readResult) {
         break;
      }
      bodyReaderPtr->ReSync();
   }
   return 0;
}

It runs fine and gives the following output:
Code:
bodySID: 0
MakeGCReader(bodySID): 1
Tell(): 0
readResult: 1
bodySID: 0
MakeGCReader(bodySID): 0
Tell(): 188
readResult: 1
bodySID: 0
MakeGCReader(bodySID): 0
Tell(): 229655000
readResult: 1
bodySID: 0
MakeGCReader(bodySID): 0
Tell(): 229711096
readResult: 1
bodySID: 0
MakeGCReader(bodySID): 0
Tell(): 412787485
readResult: 1
bodySID: 0
MakeGCReader(bodySID): 0
Tell(): 412832483
readResult: 1
bodySID: 0
MakeGCReader(bodySID): 0
Tell(): 412832671
...

 Profile WWW  

Offline
Board User

Joined: Tue Mar 09, 2010 12:30 pm
Posts: 8
Location: Poland, Poznan

Post Posted: Thu Apr 08, 2010 10:35 am 
Top  
Matt, I'm sorry I took your time.
When I read your post I analyzed my code again and I realized that I hadn't set inFilePtr.
Now it seems to work well.
I am so stupid or blind...

I'm really sorry.

Now I'll try to get JPEG2000 files.

 Profile  

Offline
Insider

Joined: Thu Apr 15, 2004 10:39 am
Posts: 198
Location: Scotland

Post Posted: Fri Apr 09, 2010 8:39 am 
Top  
No problem - glad that I helped to solve it in the end!

 Profile WWW  

Offline
Board User

Joined: Tue Mar 09, 2010 12:30 pm
Posts: 8
Location: Poland, Poznan

Post Posted: Tue Apr 27, 2010 3:02 pm 
Top  
Hi Matt, it's me again.

Now I've got another problem.
I can't create an EssenceParser object.
I've done exactly what you wrote in the MXF book.
Code:
EssenceParserPtr mainParser = new EssenceParser;

First I couldn't compile it, because I got an error:
error C2248: 'mxflib::EssenceParser::EssenceParser' : cannot access private member declared in class 'mxflib::EssenceParser'

When I changed it in the essence.h file to a public member it's fine.

The second error which I received:
error C2440: 'initializing' : cannot convert from 'mxflib::EssenceParser *' to 'mxflib::SmartPtr<T>'

I declared EssenceParserPtr in my header file:
Code:
typedef SmartPtr<EssenceParser> EssenceParserPtr;

Have you got any idea how I can fix it?

Regards,
Bernard

PS.
I found a small mistake in the MXF book, on page 330. There is an example code. In the last if statement is:
Code:
if(BodyParser()->Eof()) break;


and should be (IMHO)
Code:
if(BodyParser->Eof()) break;

because BodyParser is not a function but an object.

 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

Jump to:  


Who is online

Users browsing this forum: No registered users and 68 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group :: Style based on FI Subice by phpBBservice.nl :: All times are UTC