static int open_f(stream_t *stream,int mode, void* opts, int* file_format) {

    int res;
  loff_t len;
  PVFile*    ipFilePtr = (PVFile*)(stream->fd);    
  res=ipFilePtr->Seek(0, Oscl_File::SEEKEND);
  if(res ==-1)
      return STREAM_ERROR;
  else
      len = ipFilePtr->Tell();
  
  ipFilePtr->Seek(0, Oscl_File::SEEKSET);

  if(len == -1) {
    if(mode == STREAM_READ) stream->seek = seek_forward;
    stream->type = STREAMTYPE_STREAM; // Must be move to STREAMTYPE_FILE
    stream->flags |= STREAM_SEEK_FW;
  } else if(len >= 0) {
    stream->seek = seek;
    stream->end_pos = len;
    stream->type = STREAMTYPE_FILE;
  }
  stream->fill_buffer = fill_buffer;
  stream->write_buffer = write_buffer;
  stream->control = control;

  m_struct_free(&stream_opts,opts);
  return STREAM_OK;
}
static int control(stream_t *s, int cmd, void *arg) {
  int res;
  loff_t size;
  PVFile*    ipFilePtr = (PVFile*)(s->fd);    

  switch(cmd) {
    case STREAM_CTRL_GET_SIZE: {
      res=ipFilePtr->Seek(0, Oscl_File::SEEKEND);

      if(res == -1)
  	  return STREAM_UNSUPPORTED;
      else
	  size = ipFilePtr->Tell();
	
      ipFilePtr->Seek(s->pos, Oscl_File::SEEKSET);

      if(size != (loff_t)-1) {
        *((loff_t*)arg) = size;
        return 1;
      }
	  break;
    }
    case STREAM_CTRL_RESET:{
        //ipFilePtr->Seek(0, Oscl_File::SEEKSET);
    }
  case STREAM_CTRL_SET_AVSYNC:{
	  break;
  }
	  
		
  }
  return STREAM_UNSUPPORTED;
}