示例#1
0
int main ()
{
	float CENTER = 79.5;
	float OFFSET = 0.05;
	
	drone_connect();
	
	enable_drone_vision();	
	drone_front_camera();
	
	sleep(2);
	
	drone_takeoff();
	
	printf("Black button to exit test loop and land the drone");
	
	float x, y;
	
	track_update();
	while(!black_button())
	{
		x = OFFSET * ((track_x(0,0) - CENTER) / CENTER);
		y = OFFSET * ((track_y(0,0) - CENTER) / CENTER);
		
		if(track_count(0) > 0)
		{
			printf("Items tracking: %d\n", track_count(0));
			drone_move(0,0, x, y);
		}
		els	
		{
			printf("No items: Hovering \n");
			drone_hover();
		}
		sleep(4);
		track_update();
	}
		
	printf("Landing");
	drone_move(0,0,0,-.25);
	sleep(0.5);
	
	drone_land();
	
	drone_disconnect();
	
	return 0;
}
示例#2
0
void FORTE_TrkEclipse::executeEvent(int pa_nEIID){
  QO() = QI();
  switch (pa_nEIID){
    case scm_nEventREQID:
      if(true == QI()){
        //TODO: test with and without type casts
        track_update(); // get new image data
        COUNT() = static_cast<TForteInt16>(track_count(CH()));

        if(COUNT() > I_BLOB()){ // there is at least I_BLOBs on CH()
          SIZE() = static_cast<TForteInt16>(track_size(CH(), I_BLOB())); //
          FRAME() = static_cast<TForteInt16>(track_get_frame()); //
          CONFIDENCE() = static_cast<TForteInt16>(track_confidence(CH(), I_BLOB()));
          X() = static_cast<TForteInt16>(track_x(CH(), I_BLOB())); // get image  data
          Y() = static_cast<TForteInt16>(track_y(CH(), I_BLOB())); //    and data
          MAJOR() = static_cast<TForteInt16>(track_major_axis(CH(), I_BLOB())); // get image  data
          MINOR() = static_cast<TForteInt16>(track_minor_axis(CH(), I_BLOB())); //    and data

          if(true == INFO()){
            if(COUNT() > I_BLOB()){ // there is a blob
              printf("On Channel=%d  Eclipse Blob#%d is at (X,Y,MAJOR,MINOR)=(%d,%d,%d,%d)\n", (int) CH(), (int) I_BLOB(), (int) X(), (int) Y(), (int) MAJOR(), (int) MINOR());
              printf("\t Confidence=%d; Size=%d;Frame=%d\n", (int) CONFIDENCE(), (int) SIZE(), (int) FRAME());
            }
            else{
              printf("No Blob#%i in sight on Color Channel %i\n", (int) I_BLOB(), (int) CH());
            }
          }

        }

      }
      sendOutputEvent(scm_nEventCNFID);
      break;
  }
}
示例#3
0
blargg_err_t Gme_File::remap_track_( int* track_io ) const
{
	if ( (unsigned) *track_io >= (unsigned) track_count() )
		return BLARGG_ERR( BLARGG_ERR_CALLER, "invalid track" );
	
	if ( (unsigned) *track_io < (unsigned) playlist.size() )
	{
		M3u_Playlist::entry_t const& e = playlist [*track_io];
		*track_io = 0;
		if ( e.track >= 0 )
		{
			*track_io = e.track;
			// TODO: really needs to be removed?
			//if ( !(type_->flags_ & 0x02) )
			//  *track_io -= e.decimal_track;
		}
		if ( *track_io >= raw_track_count_ )
			return BLARGG_ERR( BLARGG_ERR_FILE_CORRUPT, "invalid track in m3u playlist" );
	}
	else
	{
		check( !playlist.size() );
	}
	return blargg_ok;
}
示例#4
0
static void
garmin_txt_write(void)
{
    char *grid_str, *c;
    const char *datum_str;

    grid_str = xstrdup(gt_get_mps_grid_longname(grid_index, MYNAME));
    while ((c = strchr(grid_str, '*'))) *c = 0xB0;	/* degree sign */
    cet_gbfprintf(fout, &cet_cs_vec_cp1252, "Grid\t%s\r\n", grid_str);
    xfree(grid_str);

    datum_str = gt_get_mps_datum_name(datum_index);
    gbfprintf(fout, "Datum\t%s\r\n\r\n", datum_str);

    waypoints = 0;
    gtxt_flags.enum_waypoints = 1;			/* enum all waypoints */
    waypt_disp_all(enum_waypt_cb);
    route_disp_all(NULL, NULL, enum_waypt_cb);
    gtxt_flags.enum_waypoints = 0;

    if (waypoints > 0) {
        int i;

        wpt_a_ct = 0;
        wpt_a = (waypoint **)xcalloc(waypoints, sizeof(*wpt_a));
        waypt_disp_all(enum_waypt_cb);
        route_disp_all(NULL, NULL, enum_waypt_cb);
        qsort(wpt_a, waypoints, sizeof(*wpt_a), sort_waypt_cb);

        gbfprintf(fout, "Header\t%s\r\n\r\n", headers[waypt_header]);
        for (i = 0; i < waypoints; i++)
        {
            waypoint *wpt = wpt_a[i];
            write_waypt(wpt);
        }
        xfree(wpt_a);

        route_idx = 0;
        route_info = xcalloc(route_count(), sizeof(struct info_s));
        routepoints = 0;
        route_disp_all(prework_hdr_cb, prework_tlr_cb, prework_wpt_cb);
        if (routepoints > 0)
        {
            route_idx = 0;
            route_disp_all(route_disp_hdr_cb, route_disp_tlr_cb, route_disp_wpt_cb);
        }
        xfree(route_info);
    }

    route_idx = 0;
    route_info = xcalloc(track_count(), sizeof(struct info_s));
    routepoints = 0;
    track_disp_all(prework_hdr_cb, prework_tlr_cb, prework_wpt_cb);

    if (routepoints > 0) {
        route_idx = 0;
        track_disp_all(track_disp_hdr_cb, track_disp_tlr_cb, track_disp_wpt_cb);
    }
    xfree(route_info);
}
示例#5
0
// public load functions call this at end
blargg_err_t Gme_File::post_load( blargg_err_t err )
{
	if ( !track_count() )
		set_track_count( type()->track_count );
	if ( !err )
		post_load_();
	else
		unload();
	
	return err;
}
示例#6
0
static void
gtm_wr_init(const char *fname)
{
	rt_count = tr_count = 0;
	track_disp_all(NULL, NULL, count_track_waypts);
	route_disp_all(NULL, NULL, count_route_waypts);

	file_out = gbfopen_le(fname, "wb", MYNAME);	/* little endian */

	/* Header */
	fwrite_integer(file_out, 211);
	fwrite_fixedstring(file_out, "TrackMaker", 10);
	fwrite_byte(file_out, 0);
	fwrite_byte(file_out, 0);
	fwrite_byte(file_out, 8);
	fwrite_byte(file_out, 0);
	fwrite_byte(file_out, 0);
	fwrite_byte(file_out, 0);
	fwrite_byte(file_out, 0);
	fwrite_long(file_out, 0);
	fwrite_long(file_out, 16777215);
	fwrite_long(file_out, waypt_count() ? 4 : 0); /* num waypoint styles */
	fwrite_long(file_out, 0);
	fwrite_long(file_out, waypt_count()); /* num waypoints */
	fwrite_long(file_out, tr_count);
	fwrite_long(file_out, rt_count);
	fwrite_single(file_out, 0); /* maxlon */
	fwrite_single(file_out, 0); /* minlon */
	fwrite_single(file_out, 0); /* maxlat */
	fwrite_single(file_out, 0); /* minlat */
	fwrite_long(file_out, 0);
	fwrite_long(file_out, track_count()); /* num tracklog styles */
	fwrite_single(file_out, 0);
	fwrite_single(file_out, 0);
	fwrite_bool(file_out, 0);
	fwrite_bool(file_out, 0);
	fwrite_bool(file_out, 0);
	fwrite_bool(file_out, 0);
	fwrite_bool(file_out, 0);
	fwrite_bool(file_out, 0);
	fwrite_bool(file_out, 0);
	fwrite_bool(file_out, 0);
	fwrite_bool(file_out, 0);
	fwrite_bool(file_out, 0);
	fwrite_string(file_out, "Times New Roman");
	fwrite_string(file_out, "");
	fwrite_string(file_out, "");
	fwrite_string(file_out, "");

	/* User Grid and Datum */
	fwrite_null(file_out, 34);
	fwrite_integer(file_out, 217); /* WGS84 */
	fwrite_null(file_out, 22);
}
/* Global variables go below (if you absolutely need them).*/
int look_for_color_green() { 
  int x, y, color=2;  // set up for color channel 2 (green)
  while (black_button() == 0) //run till button is pressed
    { 
      track_update(); // process the most recent image
      if (track_count(color) > 0)
        { // get  x, y for the biggest blob the channel sees
           x = track_x(color,2); y = track_y(color,2); 
	        printf("Biggest blob at (%d,%d)\n",x,y); 
        }
	   else
        { printf("No color match in Frame\n"); }
      sleep(0.2);  // give print time to register
    }
    printf("Program is done.\n");
}
示例#8
0
blargg_err_t Gme_File::track_info( track_info_t* out, int track ) const
{
	out->track_count = track_count();
	out->length        = -1;
	out->loop_length   = -1;
	out->intro_length  = -1;
	out->song [0]      = 0;
	
	out->game [0]      = 0;
	out->author [0]    = 0;
	out->copyright [0] = 0;
	out->comment [0]   = 0;
	out->dumper [0]    = 0;
	out->system [0]    = 0;
	
	copy_field_( out->system, type()->system );
	
	int remapped = track;
	RETURN_ERR( remap_track_( &remapped ) );
	RETURN_ERR( track_info_( out, remapped ) );
	
	// override with m3u info
	if ( playlist.size() )
	{
		M3u_Playlist::info_t const& i = playlist.info();
		copy_field_( out->game  , i.title );
		copy_field_( out->author, i.engineer );
		copy_field_( out->author, i.composer );
		copy_field_( out->dumper, i.ripping );
		
		M3u_Playlist::entry_t const& e = playlist [track];
		copy_field_( out->song, e.name );
		if ( e.length >= 0 ) out->length       = e.length * 1000L;
		if ( e.intro  >= 0 ) out->intro_length = e.intro  * 1000L;
		if ( e.loop   >= 0 ) out->loop_length  = e.loop   * 1000L;
	}
	return 0;
}
示例#9
0
blargg_err_t Gme_File::remap_track_( int* track_io ) const
{
	if ( (unsigned) *track_io >= (unsigned) track_count() )
		return "Invalid track";
	
	if ( (unsigned) *track_io < (unsigned) playlist.size() )
	{
		M3u_Playlist::entry_t const& e = playlist [*track_io];
		*track_io = 0;
		if ( e.track >= 0 )
		{
			*track_io = e.track;
			if ( !(type_->flags_ & 0x02) )
				*track_io -= e.decimal_track;
		}
		if ( *track_io >= raw_track_count_ )
			return "Invalid track in m3u playlist";
	}
	else
	{
		check( !playlist.size() );
	}
	return 0;
}
示例#10
0
static void
lowranceusr_merge_track_tlr(const route_head *trk)
{
	short num_trail_points, max_trail_size;
	char visible=1;

	if (trail_count == track_count())	/* last trail */
	{
		num_trail_points = trail_point_count;
		max_trail_size = MAX_TRAIL_POINTS;
		if (num_trail_points > max_trail_size)
			num_trail_points = max_trail_size;
		num_section_points = num_trail_points;

		if (global_opts.debug_level >= 1)
			printf(MYNAME " merge_track_tlr: num_trail_points = %d\nmax_trail_size = %d\nnum_section_points = %d\n",
				num_trail_points, max_trail_size, num_section_points);

		gbfwrite(&visible, 1, 1, file_out);
		gbfputint16(num_trail_points, file_out);
		gbfputint16(max_trail_size, file_out);
		gbfputint16(num_section_points, file_out);
	}
}
示例#11
0
int main()
{

	//Init Variables
	int color = RED;
	int lastSeen = right;
	int pumpTime = 0;
	
	//Enable Servos
	enable_servos();
	sleep(.2);
	beep();
	
	while(1) {
		
		//Check if we have time left on our Pump Counter
		if(pumpTime > 0) {
			//Turn Pump On
			set_servo_position(servoPump, pumpOn);
		}
		else {
			//Turn Pump Off
			set_servo_position(servoPump, pumpOff);
		}
		
		//Image Capture
		track_update();
		
		//Check if We See a blob
		if(track_count(color) > 0 ) {
			
			//Find out where blobs are
			//Left
			if( track_x(color, 0) < 80) {
				move(diagLeft, 500);
				lastSeen = left;
			}
			//Right
			else if( track_x(color, 0) > 120 ) {
				move(diagRight, 500);
				lastSeen = right;
			}
			//Middle
			else {
				move(forward, 500);
			}
			
			//Check if the Blob is close
			if( track_bbox_top(color, 0) > 80) {
				
				//Motors Off
				ao();
				//Extend Arm (Triggers Pneumatics)
				set_servo_position(servoSwitch, 44);
				sleep(1);
				//Retract Arm (Triggers Pneumatics)
				set_servo_position(servoSwitch, 1024);
				sleep(1);
				
				//We need to refill tanks
				pumpTime += 100;
			}
			
			//****Screen Debug Info****
			//printf("red blobs: %d\n", track_count(color));
			printf("Blob X Cord: %d\n", track_x(color,0));
			printf("Blob Y Cord: %d\n", track_y(color,0));
			//printf("Blob Box Height: %d\n", track_bbox_height(color,0));
			//printf("Blob Box Width: %d\n", track_bbox_width(color,0));
			printf("track_size: %d\n", track_size(color, 0));
			printf( "top y: %d\n\n", track_bbox_top(color, 0));
					
		}
		//Else We didn't find a blob
		else{
			
			printf( "Don't see the color blob.\n" );
			// Search for ball using last known direction
			move(lastSeen, 500); 
			
		}
		
		//Decrement PumpTime
		if(pumpTime > 0) pumpTime--;
		
	}
	
}
示例#12
0
blargg_err_t Gme_File::post_load()
{
	if ( !track_count() )
		set_track_count( type()->track_count );
	return Gme_Loader::post_load();
}
示例#13
0
blargg_err_t Gme_File::track_info( track_info_t* out, int track ) const
{
	out->track_count   = track_count();
	out->length        = -1;
	out->loop_length   = -1;
	out->intro_length  = -1;
	out->fade_length   = -1;
	out->play_length   = -1;
	out->repeat_count  = -1;
	out->song      [0] = 0;
	out->game      [0] = 0;
	out->author    [0] = 0;
	out->composer  [0] = 0;
	out->engineer  [0] = 0;
	out->sequencer [0] = 0;
	out->tagger    [0] = 0;
	out->copyright [0] = 0;
	out->date      [0] = 0;
	out->comment   [0] = 0;
	out->dumper    [0] = 0;
	out->system    [0] = 0;
	out->disc      [0] = 0;
	out->track     [0] = 0;
	out->ost       [0] = 0;
	
	copy_field_( out->system, type()->system );
	
	int remapped = track;
	RETURN_ERR( remap_track_( &remapped ) );
	RETURN_ERR( track_info_( out, remapped ) );
	
	// override with m3u info
	if ( playlist.size() )
	{
		M3u_Playlist::info_t const& i = playlist.info();
		copy_field_( out->game     , i.title );
		copy_field_( out->author   , i.artist );
		copy_field_( out->engineer , i.engineer );
		copy_field_( out->composer , i.composer );
		copy_field_( out->sequencer, i.sequencer );
		copy_field_( out->copyright, i.copyright );
		copy_field_( out->dumper   , i.ripping );
		copy_field_( out->tagger   , i.tagging );
		copy_field_( out->date     , i.date );
		
		M3u_Playlist::entry_t const& e = playlist [track];
		if ( e.length >= 0 ) out->length       = e.length;
		if ( e.intro  >= 0 ) out->intro_length = e.intro;
		if ( e.loop   >= 0 ) out->loop_length  = e.loop;
		if ( e.fade   >= 0 ) out->fade_length  = e.fade;
		if ( e.repeat >= 0 ) out->repeat_count = e.repeat;
		copy_field_( out->song, e.name );
	}
	
	// play_length
	out->play_length = out->length;
	if ( out->play_length <= 0 )
	{
		out->play_length = out->intro_length + 2 * out->loop_length; // intro + 2 loops
		if ( out->play_length <= 0 )
			out->play_length = 150 * 1000; // 2.5 minutes
	}
	
	return blargg_ok;
}
示例#14
0
/*----------------------------------------------------------------------
|   AP4_Processor::MuxStream
+---------------------------------------------------------------------*/
AP4_Result
AP4_Processor::MuxStream(
	AP4_Array<AP4_ByteStream *> &input,
	AP4_ByteStream& output,
	AP4_UI08		partitions,
	AP4_AtomFactory& atom_factory)
{
	AP4_Result		result;
	AP4_UI64		stream_offset = 0;

	if (partitions & 1)
	{
		// read all atoms.
		// keep all atoms except [mdat]
		// keep a ref to [moov]
		// put [moof] atoms in a separate list
		AP4_AtomParent              top_level;
		AP4_Array<AP4_MoovAtom*>	moov;
		AP4_Size					track_count(0);

		for(AP4_Size streamid(0); streamid < input.ItemCount(); ++streamid)
		{
			for (AP4_Atom* atom = NULL; AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(*input[streamid], atom)); input[streamid]->Tell(stream_offset))
			{
				if (atom->GetType() == AP4_ATOM_TYPE_MFRA) {
					delete atom;
					continue;
				}
				else if (atom->GetType() == AP4_ATOM_TYPE_SIDX) {
					delete atom;
					continue;
				}
				else if (atom->GetType() == AP4_ATOM_TYPE_SSIX) {
					delete atom;
					continue;
				}
				if (streamid == 0)
					top_level.AddChild(atom);
				else if (atom->GetType() != AP4_ATOM_TYPE_MOOV)
					delete atom;
				if (atom->GetType() == AP4_ATOM_TYPE_MOOV)
				{
					moov.Append(AP4_DYNAMIC_CAST(AP4_MoovAtom,atom));
					break;
				}
			}
			if (moov.ItemCount() == streamid)
				return AP4_ERROR_INVALID_FORMAT;
			
			while (AP4_SUCCEEDED(moov[streamid]->DeleteChild(AP4_ATOM_TYPE_PSSH, 0)));

			// Remove tracks we cannot handle
			for (AP4_List<AP4_TrakAtom>::Item *item(moov[streamid]->GetTrakAtoms().FirstItem()); item;)
				if (!item->GetData()->FindChild("mdia/minf/stbl"))
					moov[streamid]->GetTrakAtoms().Remove(item);
				else
					item = item->GetNext();
			track_count += moov[streamid]->GetTrakAtoms().ItemCount();
		}

		// initialize the processor
		if (AP4_FAILED(result = Initialize(top_level, *input[0]))) 
			return result;

		// process the tracks if we have a moov atom
		m_TrackData.SetItemCount(track_count);
		m_StreamData.SetItemCount(input.ItemCount());
	
		//NormalizeTREX(mvex, 0, m_TrackCounts[0], m_TrackCounts[1]);
		AP4_Cardinal internal_index(0);
		AP4_ContainerAtom *mvex_base(0);
		AP4_List<AP4_TrakAtom>::Item *item = NULL;

		for (AP4_Size streamid(0); streamid < input.ItemCount(); ++streamid)
		{
			m_StreamData[streamid].trackStart = internal_index;
			m_StreamData[streamid].stream = input[streamid];
			if (streamid)
				moov[0]->AddTrakAtoms(moov[streamid]->GetTrakAtoms(), item);
			else
				item = moov[streamid]->GetTrakAtoms().FirstItem();

			for (; item; item = item->GetNext())
			{
				PERTRACK &track_data(m_TrackData[internal_index]);
				track_data.original_id = item->GetData()->GetId();
				item->GetData()->SetId(track_data.new_id = internal_index + 1);

        if (AP4_MdhdAtom* mdhd = AP4_DYNAMIC_CAST(AP4_MdhdAtom, item->GetData()->FindChild("mdia/mdhd")))
          track_data.timescale = mdhd->GetTimeScale();
        else
          track_data.timescale = 1;
        
        AP4_ContainerAtom *mvex = AP4_DYNAMIC_CAST(AP4_ContainerAtom, moov[streamid]->GetChild(AP4_ATOM_TYPE_MVEX, 0));
				if (!mvex)
					return AP4_ERROR_INVALID_FORMAT;
				
				if (!item->GetData()->GetDuration())
				{
					AP4_MehdAtom *mehd(AP4_DYNAMIC_CAST(AP4_MehdAtom, mvex->GetChild(AP4_ATOM_TYPE_MEHD, 0)));
					item->GetData()->SetDuration(mehd? mehd->GetDuration():0);
				}
				
				AP4_TrexAtom *trex(NULL);
				unsigned int index(0);
				for (; !trex && (trex = AP4_DYNAMIC_CAST(AP4_TrexAtom, mvex->GetChild(AP4_ATOM_TYPE_TREX, index++)));)
					if(trex->GetTrackId() != track_data.original_id)
						trex = NULL;
				if (!trex)
					return AP4_ERROR_INVALID_FORMAT;

				if (mvex_base)
				{
					trex = AP4_DYNAMIC_CAST(AP4_TrexAtom, trex->Clone());
					mvex_base->AddChild(trex);
				}
				else
					mvex_base = mvex;
				trex->SetTrackId(track_data.new_id);

				track_data.track_handler = CreateTrackHandler(item->GetData(), trex);
				track_data.track_handler->ProcessTrack();
				track_data.streamId = streamid;
				++m_StreamData[streamid].trackCount;
				++internal_index;
			}
		}
		// We don't need the other moovs anymore.....
		moov.SetItemCount(1);

		AP4_MvhdAtom *mvhd(AP4_DYNAMIC_CAST(AP4_MvhdAtom, moov[0]->GetChild(AP4_ATOM_TYPE_MVHD, 0)));
		if (!mvhd->GetDuration())
		{
			AP4_MehdAtom *mehd(AP4_DYNAMIC_CAST(AP4_MehdAtom, mvex_base->GetChild(AP4_ATOM_TYPE_MEHD, 0)));
			mvhd->SetDuration(mehd ? mehd->GetDuration() : 0);
		}

		// finalize the processor
		Finalize(top_level);

		// calculate the size of all atoms combined
		AP4_UI64 atoms_size = 0;
		top_level.GetChildren().Apply(AP4_AtomSizeAdder(atoms_size));

		// write all atoms
		top_level.GetChildren().Apply(AP4_AtomListWriter(output));
		m_MoovAtom = moov[0];
		m_MoovAtom->Detach();
	}

	if (partitions & 2)
	{
		// process the fragments, if any
		result = AP4_SUCCESS;
		AP4_Array<AP4_UI64> moof_positions, mdat_positions;
		moof_positions.SetItemCount(input.ItemCount());
		mdat_positions.SetItemCount(input.ItemCount());

		for (;;)
		{
			AP4_ContainerAtom *moof = NULL;
			AP4_UI32 track_index(0);
			
#if 0			
      for (AP4_Cardinal streamid(0); streamid < input.ItemCount(); ++streamid)
			{
				AP4_Atom* atom = NULL;
				if (AP4_SUCCEEDED(input[streamid]->Tell(stream_offset)) && AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(*input[streamid], atom)))
				{
					if (atom->GetType() != AP4_ATOM_TYPE_MOOF)
						return AP4_ERROR_INVALID_FORMAT;
					
					moof_positions[streamid] = stream_offset;
					mdat_positions[streamid] = stream_offset + atom->GetSize() + +AP4_ATOM_HEADER_SIZE;

					if (moof)
					{
						int index(0);
						for (; AP4_Atom* child = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom)->GetChild(AP4_ATOM_TYPE_TRAF, index++);)
							moof->AddChild(child->Clone());
						delete atom;
					}
					else
						moof = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
					NormalizeTRAF(AP4_DYNAMIC_CAST(AP4_ContainerAtom, moof), m_StreamData[streamid].trackStart,
						m_StreamData[streamid].trackStart + m_StreamData[streamid].trackCount, track_index);
				}
				else
					delete atom;
			}
#else
      double mindts(9999999999.0);
      AP4_Cardinal nextStream(~0);
      for (AP4_Cardinal track(0); track < m_TrackData.ItemCount(); ++track)
        if ((double)m_TrackData[track].dts / m_TrackData[track].timescale  < mindts)
        {
          mindts = (double)m_TrackData[track].dts / m_TrackData[track].timescale;
          nextStream = m_TrackData[track].streamId;
        }
      
      AP4_Atom* atom = NULL;
      if (AP4_SUCCEEDED(result = input[nextStream]->Tell(stream_offset)) && AP4_SUCCEEDED(result = atom_factory.CreateAtomFromStream(*input[nextStream], atom)))
      {
        if (atom->GetType() != AP4_ATOM_TYPE_MOOF)
          return AP4_ERROR_INVALID_FORMAT;
			} else if (atom)
				return result;

      moof_positions[nextStream] = stream_offset;
      mdat_positions[nextStream] = stream_offset + atom->GetSize() + +AP4_ATOM_HEADER_SIZE;

      moof = AP4_DYNAMIC_CAST(AP4_ContainerAtom, atom);
      NormalizeTRAF(AP4_DYNAMIC_CAST(AP4_ContainerAtom, moof), m_StreamData[nextStream].trackStart,
        m_StreamData[nextStream].trackStart + m_StreamData[nextStream].trackCount, track_index);
#endif
			if (!moof)
				break;
			
			if (AP4_FAILED(result = ProcessFragment(moof, NULL, 0, output, moof_positions, mdat_positions)))
				return result;
			
			delete moof;
			moof = NULL;
		}

		// cleanup
		m_TrackData.Clear();
		m_StreamData.Clear();
	}

	return AP4_SUCCESS;
}
示例#15
0
static void
data_write(void)
{
	short int NumWaypoints, MajorVersion, MinorVersion, NumRoutes, NumTrails, NumIcons;
	setshort_length(mkshort_handle, 15);
	MajorVersion = writing_version;
	MinorVersion = 0;

	NumWaypoints = waypt_count();

	gbfputint16(MajorVersion, file_out);
	gbfputint16(MinorVersion, file_out);

	if (global_opts.debug_level >= 1)
		printf(MYNAME " data_write: Num waypoints = %d\n", NumWaypoints);

	if (writeasicons) {
		short zero = 0;
		gbfputint16(zero, file_out);
	} else {
		gbfputint16(NumWaypoints, file_out);
		waypt_disp_all(lowranceusr_waypt_pr);
	}

	/* Route support added 6/21/05 */
	NumRoutes = route_count();
	gbfputint16(NumRoutes, file_out);

	if (global_opts.debug_level >= 1)
		printf(MYNAME " data_write: Num routes = %d\n", NumRoutes);

	if (NumRoutes)
	{
		lowrance_route_count=0;
		route_disp_all(lowranceusr_route_hdr, NULL, lowranceusr_waypt_disp);
	}

	if (NumWaypoints && writeasicons) {
		gbfputint16(NumWaypoints, file_out);
		waypt_disp_all(lowranceusr_write_icon);
	} else {
		NumIcons = 0;
		gbfputint16(NumIcons, file_out);
	}
	
	/* Track support added 6/21/05 */
	NumTrails = track_count();

	if (NumTrails && merge)
	{
		NumTrails = 1;
		gbfputint16(NumTrails, file_out);
		trail_point_count = 0;
		trail_count = 0;
		/* count the number of total track points */
		track_disp_all(lowranceusr_merge_track_hdr, lowranceusr_merge_track_tlr, NULL);
		/* write out the new track header */
		trail_point_count = 0;
		track_disp_all(lowranceusr_merge_track_hdr_2, NULL, lowranceusr_track_disp);

	}
	else
	{
	
		gbfputint16(NumTrails, file_out);

		if (global_opts.debug_level >= 1)
			printf(MYNAME " data_write: Num tracks = %d\n", NumTrails);

		if (NumTrails)
		{
			trail_count=0;
			track_disp_all(lowranceusr_track_hdr, NULL, lowranceusr_track_disp);
		}
	}
}