/*
    This program is not linked against main library
    ( for compile time efficiency ). Instead, it
    depends only on two of its source files.
    It uses interface declared in include/ReadHandlers.h
    to access directly data in ASF file.
*/    

#include "avm_fourcc.h"
#include "asffmt.h"
#include "AsfReadHandler.h"
#include <iostream>
#include <unistd.h>

using namespace avm;

int main(int argc, char** argv)
{
//    IMediaReadHandler* h=new ASFReadHandler("/d/movies/Eyes on me.asf");
//    IMediaReadHandler* h=new ASFReadHandler("/d/movies/Baby one more time.asf");
    const char* filename="/d/test-movies/smth.asf";
    if(argc>1)filename=argv[1];
    IMediaReadHandler* h=new ASFReadHandler(filename);
//    sleep(20);
    char ttt[100000];
    IMediaReadStream* s=h->GetStream(mmioFOURCC('a', 'u', 'd', 's'), 0);
    uint_t samp_read, bytes_read;
    s->Read(&ttt, 10000U, 5U, &bytes_read, &samp_read);
    std::cout<<"Now video"<<std::endl;
	IMediaReadStream* s1=h->GetStream(mmioFOURCC('v', 'i', 'd', 's'), 0);
    for(int i=0; i<100; i++)
    {
	s1->Read(0, 0, 1, &bytes_read, &samp_read);
	std::cout<<i<<" : Size "<<bytes_read<<std::endl;
	s1->Read(&ttt, bytes_read, 1, &bytes_read, &samp_read);
    }
    return 0;
}
