示例#1
0
LocalMediaStream::LocalMediaStream(const talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface>& pStream)
    : FB::JSAPIAuto("MediaStream")
    , m_label(pStream->label())
    , m_videoTracks(FB::variant_list_of())
    , m_audioTracks(FB::variant_list_of())
{
    registerProperty("label", make_property(this, &LocalMediaStream::get_label));
    registerProperty("videoTracks", make_property(this,&LocalMediaStream::get_videoTracks));
    registerProperty("audioTracks", make_property(this, &LocalMediaStream::get_audioTracks));

    for(int i=0; i<pStream->video_tracks()->count(); i++)
    {
        talk_base::scoped_refptr<webrtc::VideoTrackInterface> pTrack(pStream->video_tracks()->at(i));
        talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> pTrack_(
            static_cast<webrtc::LocalVideoTrackInterface*>(pTrack.get())
        );

        AddTrack(LocalVideoTrack::Create(pTrack_));
    }

    for(int i=0; i<pStream->audio_tracks()->count(); i++)
    {
        talk_base::scoped_refptr<webrtc::AudioTrackInterface> pTrack(pStream->audio_tracks()->at(i));
        talk_base::scoped_refptr<webrtc::LocalAudioTrackInterface> pTrack_(
            static_cast<webrtc::LocalAudioTrackInterface*>(pTrack.get())
        );

        AddTrack(LocalAudioTrack::Create(pTrack_));
    }
}
示例#2
0
//----------------------------------------------
//	get track info from URI
//----------------------------------------------
TRef TLSpotify::TSession::FindTrack(const TString& URI)
{
	THeapArray<char> UriString;
	URI.GetAnsi( UriString );
	
	//	find link
	sp_link *link = sp_link_create_from_string( UriString.GetData() );
    if (!link) 
		return TRef();
	
	//	get track from the link
	sp_track* pTrack = sp_link_as_track( link );
	if ( !pTrack )
	{
		TDebugString Debug_String;
		Debug_String << "URI " << URI << " is not a track";
		TLDebug_Print( Debug_String );
		return TRef();
	}
	
	//	create new track info
	TRef TrackRef = AddTrack( *pTrack );
	
	const char* TrackName = sp_track_name( pTrack );
	
    //	The create function will have increased the reference count for us so release
    sp_link_release(link);
	
	return TrackRef;
}
示例#3
0
	void *m_alloc(unsigned long size, const char *file, unsigned long line)
	{
		ILvoid *ptr;
		ptr = malloc(size);
		if (!ptr)
			return NULL;
		AddToAtexit();
		AddTrack((unsigned long)ptr, size, file, line);
		return ptr;
	}
示例#4
0
文件: mtp.c 项目: etix/vlc
/*****************************************************************************
 * Everything else
 *****************************************************************************/
static int AddDevice( services_discovery_t *p_sd,
                      LIBMTP_raw_device_t *p_raw_device )
{
    char *psz_name = NULL;
    LIBMTP_mtpdevice_t *p_device;
    LIBMTP_track_t *p_track, *p_tmp;

    if( ( p_device = LIBMTP_Open_Raw_Device( p_raw_device ) ) != NULL )
    {
        if( !( psz_name = LIBMTP_Get_Friendlyname( p_device ) ) )
            if( !( psz_name = LIBMTP_Get_Modelname( p_device ) ) )
                if( !( psz_name = strdup( N_( "MTP Device" ) ) ) )
                    return VLC_ENOMEM;
        msg_Info( p_sd, "Found device: %s", psz_name );
        p_sd->p_sys->i_bus = p_raw_device->bus_location;
        p_sd->p_sys->i_dev = p_raw_device->devnum;
        p_sd->p_sys->i_product_id = p_raw_device->device_entry.product_id;
        if( ( p_track = LIBMTP_Get_Tracklisting_With_Callback( p_device,
                            CountTracks, p_sd ) ) == NULL )
        {
            msg_Warn( p_sd, "No tracks on the device" );
        }
        else
        {
            if( !( p_sd->p_sys->pp_items = calloc( p_sd->p_sys->i_tracks_num,
                                                   sizeof( input_item_t * ) ) ) )
            {
                free( psz_name );
                return VLC_ENOMEM;
            }
            p_sd->p_sys->i_count = 0;
            while( p_track != NULL )
            {
                msg_Dbg( p_sd, "Track found: %s - %s", p_track->artist,
                         p_track->title );
                AddTrack( p_sd, p_track );
                p_tmp = p_track;
                p_track = p_track->next;
                LIBMTP_destroy_track_t( p_tmp );
            }
        }
        p_sd->p_sys->psz_name = psz_name;
        LIBMTP_Release_Device( p_device );
        return VLC_SUCCESS;
    }
    else
    {
        msg_Info( p_sd, "The device seems to be mounted, unmount it first" );
        return VLC_EGENERIC;
    }
}
示例#5
0
文件: dialog.cpp 项目: pan-mroku/yarl
Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
    this->setLayout(ui->verticalLayout);
    model=new QStandardItemModel();
    model->setHorizontalHeaderLabels(QStringList({"Title", "Duration"}));
    ui->tableView->setModel(model);
    ui->tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);

    connect(ui->AddButton, SIGNAL(clicked()), this, SLOT(AddTrack()));
    connect(ui->RemoveButton, SIGNAL(clicked()), this, SLOT(DelTrack()));
    connect(ui->UpButton, SIGNAL(clicked()), this, SLOT(PopTrack()));
    connect(ui->DownButton, SIGNAL(clicked()), this, SLOT(PushTrack()));
    NewArtist=NULL;
}
示例#6
0
GpxRootElement::GpxRootElement(const wxString &creator, GpxMetadataElement *metadata, ListOfGpxWpts *waypoints, ListOfGpxRoutes *routes, ListOfGpxTracks *tracks, GpxExtensionsElement *extensions) : TiXmlElement("gpx")
{
      my_extensions = NULL;
      my_metadata = NULL;
      first_waypoint = NULL;
      last_waypoint = NULL;
      first_route = NULL;
      last_route = NULL;
      first_track = NULL;
      last_track = NULL;

      SetAttribute ( "version", "1.1" );
      SetAttribute ( "creator", creator.ToUTF8() );
      SetAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
      SetAttribute( "xmlns", "http://www.topografix.com/GPX/1/1" );
      SetAttribute( "xmlns:gpxx", "http://www.garmin.com/xmlschemas/GpxExtensions/v3" );
      SetAttribute( "xsi:schemaLocation", "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" );
      SetMetadata(metadata);
      if (waypoints) {
            wxListOfGpxWptsNode *waypoint = waypoints->GetFirst();
            while (waypoint)
            {
                  AddWaypoint(waypoint->GetData());
                  waypoint = waypoint->GetNext();
            }
      }
      if (routes) {
            wxListOfGpxRoutesNode *route = routes->GetFirst();
            while (route)
            {
                  AddRoute(route->GetData());
                  route = route->GetNext();
            }
      }
      if (tracks) {
            wxListOfGpxTracksNode *track = tracks->GetFirst();
            while (track)
            {
                  AddTrack(track->GetData());
                  track = track->GetNext();
            }
      }
      SetExtensions(extensions);
}
示例#7
0
CDDBData::CDDBData(const CDDBData &from)
	:
	fDiscID(from.fDiscID),
 	fArtist(from.fArtist),
 	fAlbum(from.fAlbum),
 	fGenre(from.fGenre),
 	fDiscTime(from.fDiscTime),
	fYear(from.fYear)
{
	STRACE(("CDDBData::Copy Constructor\n"));

	for (int32 i = 0; i < from.fTrackList.CountItems(); i++) {
		BString *string = (BString*)from.fTrackList.ItemAt(i);
		CDAudioTime *time = (CDAudioTime*)from.fTimeList.ItemAt(i);

		if (!string || !time)
			continue;

		AddTrack(string->String(), *time);
	}
}
示例#8
0
CDDBData &
CDDBData::operator=(const CDDBData &from)
{
	_EmptyLists();
	fDiscID = from.fDiscID;
 	fArtist = from.fArtist;
 	fAlbum = from.fAlbum;
 	fGenre = from.fGenre;
 	fDiscTime = from.fDiscTime;
	fYear = from.fYear;

	for (int32 i = 0; i < from.fTrackList.CountItems(); i++) {
		BString *string = (BString*)from.fTrackList.ItemAt(i);
		CDAudioTime *time = (CDAudioTime*)from.fTimeList.ItemAt(i);

		if (!string || !time)
			continue;

		AddTrack(string->String(),*time);
	}
	return *this;
}
 void TrackUnionStream::ProcessInput(GraphTime aFrom, GraphTime aTo, uint32_t aFlags)
 {
   if (IsFinishedOnGraphThread()) {
     return;
   }
   nsAutoTArray<bool,8> mappedTracksFinished;
   nsAutoTArray<bool,8> mappedTracksWithMatchingInputTracks;
   for (uint32_t i = 0; i < mTrackMap.Length(); ++i) {
     mappedTracksFinished.AppendElement(true);
     mappedTracksWithMatchingInputTracks.AppendElement(false);
   }
   bool allFinished = !mInputs.IsEmpty();
   bool allHaveCurrentData = !mInputs.IsEmpty();
   for (uint32_t i = 0; i < mInputs.Length(); ++i) {
     MediaStream* stream = mInputs[i]->GetSource();
     if (!stream->IsFinishedOnGraphThread()) {
       // XXX we really should check whether 'stream' has finished within time aTo,
       // not just that it's finishing when all its queued data eventually runs
       // out.
       allFinished = false;
     }
     if (!stream->HasCurrentData()) {
       allHaveCurrentData = false;
     }
     bool trackAdded = false;
     for (StreamBuffer::TrackIter tracks(stream->GetStreamBuffer());
          !tracks.IsEnded(); tracks.Next()) {
       bool found = false;
       for (uint32_t j = 0; j < mTrackMap.Length(); ++j) {
         TrackMapEntry* map = &mTrackMap[j];
         if (map->mInputPort == mInputs[i] && map->mInputTrackID == tracks->GetID()) {
           bool trackFinished;
           StreamBuffer::Track* outputTrack = mBuffer.FindTrack(map->mOutputTrackID);
           if (!outputTrack || outputTrack->IsEnded()) {
             trackFinished = true;
           } else {
             CopyTrackData(tracks.get(), j, aFrom, aTo, &trackFinished);
           }
           mappedTracksFinished[j] = trackFinished;
           mappedTracksWithMatchingInputTracks[j] = true;
           found = true;
           break;
         }
       }
       if (!found && (!mFilterCallback || mFilterCallback(tracks.get()))) {
         bool trackFinished = false;
         trackAdded = true;
         uint32_t mapIndex = AddTrack(mInputs[i], tracks.get(), aFrom);
         CopyTrackData(tracks.get(), mapIndex, aFrom, aTo, &trackFinished);
         mappedTracksFinished.AppendElement(trackFinished);
         mappedTracksWithMatchingInputTracks.AppendElement(true);
       }
     }
     if (trackAdded) {
       for (MediaStreamListener* l : mListeners) {
         l->NotifyFinishedTrackCreation(Graph());
       }
     }
   }
   for (int32_t i = mTrackMap.Length() - 1; i >= 0; --i) {
     if (mappedTracksFinished[i]) {
       EndTrack(i);
     } else {
       allFinished = false;
     }
     if (!mappedTracksWithMatchingInputTracks[i]) {
       mTrackMap.RemoveElementAt(i);
     }
   }
   if (allFinished && mAutofinish && (aFlags & ALLOW_FINISH)) {
     // All streams have finished and won't add any more tracks, and
     // all our tracks have actually finished and been removed from our map,
     // so we're finished now.
     FinishOnGraphThread();
   } else {
     mBuffer.AdvanceKnownTracksTime(GraphTimeToStreamTime(aTo));
   }
   if (allHaveCurrentData) {
     // We can make progress if we're not blocked
     mHasCurrentData = true;
   }
 }
sbError
sbiTunesAgentProcessor::ProcessTaskFile()
{
  int retry = 60;

  if (!OpenResultsFile()) {
    return sbError("Failed to open results file to check for start!");
  }
  
  if (OpenResultsFile().tellp() == std::ofstream::pos_type(0)) {
    OpenResultsFile() << '[' << SCHEMA_VERSION << ":2]\n"
                      << '[' << ADDED_MEDIA_ITEMS << "]\n";
  }

  // Keep process all files we find
  while (OpenTaskFile(mInputStream)) {
    if (!mInputStream) {
      // Can't open, maybe it's being written to try again
      if (--retry == 0) {
        return sbError("Unable to open the export track file");
      }
      Sleep(1000);
      continue;
    }
    sbError const & error = Initialize();
    if (error && !ErrorHandler(error)) {
      return error;
    }
    std::string line;
    std::string action;
    std::string source;
    int lineno = 0;
    while (std::getline(mInputStream, line)) {
      std::string::size_type const beginBracket = 
        line.find_first_not_of(" \t");
      // Look for the right bracket as first non-whitespace
      if (beginBracket != std::string::npos && line[beginBracket] == '[') {
        std::string::size_type const endBracket = line.find_last_of(']');
        if (endBracket != std::string::npos) {
          std::string task = line.substr(beginBracket + 1, 
                                         endBracket - beginBracket - 1);
          ParseTask(task, action, source);
          if (action == SCHEMA_VERSION) {
            VersionAction const versionAction = VersionCheck(source);
            action.clear();
            source.clear();
            if (versionAction == ABORT) {
              return sbError("Incompatible version encountered");
            }
            else if (versionAction == RETRY) {
              mInputStream.close();
              continue; // Will hit the inner while and it will stop
            }
          }

          sbError error = ProcessPendingTrackBatch();
          SB_ENSURE_ERRORHANDLER(error);
        }
      }
      else {
        // If there is no action then there's nothing to do yet
        if (action.empty()) {
          ++lineno;
          continue;
        }
        std::string::size_type const equalSign = line.find('=');
        if (equalSign != std::string::npos) {
          std::string const & key =
            Strip(line.substr(0, equalSign));
          std::string const & value =
            Unescape(Strip(line.substr(equalSign + 1)));

          // We've been told to add the track
          if (action == ADDED_MEDIA_ITEMS) {
            sbError const & error = AddTrack(source, key, value, ADDED_MEDIA_ITEMS);
            SB_ENSURE_ERRORHANDLER(error);
          }
          else if (action == UPDATED_MEDIA_ITEMS) {
            sbError const & error = UpdateTrack(key, value);
            SB_ENSURE_ERRORHANDLER(error);
          }
          else if (action == ADDED_PLAYLISTS) {
            sbError error = CreatePlaylist(value);
            SB_ENSURE_ERRORHANDLER(error);
          }
          // We've been told to remove the playlist
          else if (action == DELETED_PLAYLISTS) {
            sbError error = RemovePlaylist(value);
            SB_ENSURE_ERRORHANDLER(error);
          }
          else if (action == UPDATED_SMARTPLAYLIST) {
            sbError const & error = AddTrack(source,
                                             key,
                                             value,
                                             UPDATED_SMARTPLAYLIST);
            SB_ENSURE_ERRORHANDLER(error);
          }
          else {
            std::ostringstream msg;
            msg << action << " is an invalid action , ignoring line " 
                << lineno;
            sbError error(msg.str());
            SB_ENSURE_ERRORHANDLER(error);

            action.clear();
          }
        }
        else {
          // If the line wasn't blank then report an error
          if (!Strip(line).empty()) {
            std::ostringstream msg;
            msg << action 
                << " is an invalid action , ignoring line " << lineno;
            sbError error(msg.str());
            SB_ENSURE_ERRORHANDLER(error);
          }
        }
      }
      ++lineno;
      if (ShouldShutdown()) {
        // Notify shutdown done and exit
        ShutdownDone();
        return sbNoError;
      }
    }
    if (!mTrackBatch.empty()) {
      sbError const & error = ProcessPendingTrackBatch();
      SB_ENSURE_ERRORHANDLER(error);
    }
    // Close the stream and remove the file
    mInputStream.close();
    mInputStream.clear();
    RemoveTaskFile();
  }
  return sbNoError;
}
示例#11
0
void
TrackWindow::MessageReceived( BMessage * msg )
{
	switch (msg->what)
	{
		case VolumeQuery::BEGIN_FETCH:
		{
			m_fetching++;
		}	break;
		case VolumeQuery::END_FETCH:
		{
			m_fetching--;
			
			if ( !m_fetching )
			{ // no more fetches underway, add to list
				//printf("sorting tracks..\n");
				
				// m_fetched_items.SortItems( compare_track_items );

				//printf("adding tracks..\n");
				
				m_list->SupressUpdates(true);
				
				for ( int i=0; i<m_fetched_items.CountItems(); i++ )
				{ // add items to list
					TrackItem * item = (TrackItem*)m_fetched_items.ItemAt(i);
					
					if ( !item )
					{
						//printf("Something fishy..\n");
						continue;
					}
					
					AddTrack( item, false );
				}
				
				SortTracks();
				
				m_list->SupressUpdates(false);
			}
		}	break;
		case LIST_INVOKE:
		{
			TrackItem * item = dynamic_cast<TrackItem*>(m_list->CurrentSelection());
			
			if ( item )
			{
				// send message to playlist window!
				// DON'T -- be_roster->Launch( item->GetTrack()->GetEntry() );
				BMessage playmsg( PlayList::PLAY_FILE );
				playmsg.AddRef( "file", item->GetTrack()->GetEntry() );
				
				m_playlist_messenger.SendMessage( &playmsg );
			} else {
				BetterListItem * i = m_list->CurrentSelection();
				
				if ( i->IsExpanded() )
					m_list->Collapse( i );
				else
					m_list->Expand( i );
			}
		}	break;
		case B_QUERY_UPDATE:
		{
			int32 op = 0;
			int64 node = 0;
			msg->FindInt32("opcode",&op);
			msg->FindInt64("node",&node);
			
			switch ( op )
			{
				case B_ENTRY_CREATED:
				{
					const char	* name;
					dev_t		device;
					ino_t		directory;
					ino_t		node;
					
					msg->FindString("name", &name );
					msg->FindInt64("directory", &directory);
					msg->FindInt32("device", &device);
					msg->FindInt64("node", &node);
					
					bool found = false;
					for ( int c=0; m_list->ItemAt(c); c++ )
					{
						TrackItem * item = dynamic_cast<TrackItem*>(m_list->ItemAt(c));
						
						if ( item && item->IsNode(node) )
						{
							found = true;
							break;
						}
					}
					
					if ( !found )
					{ // a new file is added
						entry_ref ref( device, directory, name );
						
						TrackItem * item = new TrackItem( new Track(&ref), false );
						
						m_info->TrackAdded( item->GetTrack() );
						
						if ( m_fetching )
						{
							m_fetched_items.AddItem( item );
						} else
						{
							AddTrack( item );
							SortTracks();
						}
					}
				}	break;
				case B_ENTRY_REMOVED:
				{
					for ( int c=0; m_list->ItemAt(c); c++ )
					{
						TrackItem * item = dynamic_cast<TrackItem*>(m_list->ItemAt(c));
						
						if ( item && item->IsNode(node) )
						{
							m_info->TrackRemoved( item->GetTrack() );
							
							BetterListItem * album = m_list->Superitem(item);
							
							m_list->RemoveItem( item );
							
							delete item;
							
							// remove album if empty
							if ( m_list->CountItemsUnder(album,true) == 0 )
							{
								BetterListItem * artist = m_list->Superitem(album);
								
								m_list->RemoveItem( album );
								
								delete album;
								
								// remove artist if empty
								if ( m_list->CountItemsUnder(artist,true) == 0 )
								{
									m_list->RemoveItem( artist );
									
									delete artist;
								}
							}
							
							// if last track in album and/or last album in artist
							// delete these as well
							break;
						}
					}
					
				}	break;
				default:
					break;
			}
		}	break;
		default:
			BWindow::MessageReceived(msg);
	}
}
void FSpawnTrackEditor::HandleAddSpawnTrackMenuEntryExecute(FGuid ObjectBinding)
{
	FScopedTransaction AddSpawnTrackTransaction(LOCTEXT("AddSpawnTrack_Transaction", "Add Spawn Track"));
	AddTrack(GetSequencer()->GetFocusedMovieSceneSequence()->GetMovieScene(), ObjectBinding, UMovieSceneSpawnTrack::StaticClass(), NAME_None);
	NotifyMovieSceneDataChanged();
}
示例#13
0
Firnplayer::ListAlbum::ListAlbum(Json::Value * TrackJson)
{
  this->Name = (*TrackJson)["TALB"].asString();
  AddTrack(TrackJson);
}
示例#14
0
Firnplayer::ListArtist::ListArtist(Json::Value * TrackJson)
{
  this->Name = (*TrackJson)["TPE2"].asString();
  Expanded = false;
  AddTrack(TrackJson);
}
示例#15
0
void TrackUnionStream::ProcessInput(GraphTime aFrom, GraphTime aTo,
                                    uint32_t aFlags) {
  TRACE_AUDIO_CALLBACK_COMMENT("TrackUnionStream %p", this);
  if (IsFinishedOnGraphThread()) {
    return;
  }
  AutoTArray<bool, 8> mappedTracksFinished;
  AutoTArray<bool, 8> mappedTracksWithMatchingInputTracks;
  for (uint32_t i = 0; i < mTrackMap.Length(); ++i) {
    mappedTracksFinished.AppendElement(true);
    mappedTracksWithMatchingInputTracks.AppendElement(false);
  }

  AutoTArray<MediaInputPort*, 32> inputs(mInputs);
  inputs.AppendElements(mSuspendedInputs);

  bool allFinished = !inputs.IsEmpty();
  bool allHaveCurrentData = !inputs.IsEmpty();
  for (uint32_t i = 0; i < inputs.Length(); ++i) {
    MediaStream* stream = inputs[i]->GetSource();
    if (!stream->IsFinishedOnGraphThread()) {
      // XXX we really should check whether 'stream' has finished within time
      // aTo, not just that it's finishing when all its queued data eventually
      // runs out.
      allFinished = false;
    }
    if (!stream->HasCurrentData()) {
      allHaveCurrentData = false;
    }
    for (StreamTracks::TrackIter tracks(stream->GetStreamTracks());
         !tracks.IsEnded(); tracks.Next()) {
      bool found = false;
      for (uint32_t j = 0; j < mTrackMap.Length(); ++j) {
        TrackMapEntry* map = &mTrackMap[j];
        if (map->mInputPort == inputs[i] &&
            map->mInputTrackID == tracks->GetID()) {
          bool trackFinished = false;
          StreamTracks::Track* outputTrack =
              mTracks.FindTrack(map->mOutputTrackID);
          found = true;
          if (!outputTrack || outputTrack->IsEnded() ||
              !inputs[i]->PassTrackThrough(tracks->GetID())) {
            trackFinished = true;
          } else {
            CopyTrackData(tracks.get(), j, aFrom, aTo, &trackFinished);
          }
          mappedTracksFinished[j] = trackFinished;
          mappedTracksWithMatchingInputTracks[j] = true;
          break;
        }
      }
      if (!found && inputs[i]->AllowCreationOf(tracks->GetID())) {
        bool trackFinished = false;
        uint32_t mapIndex = AddTrack(inputs[i], tracks.get(), aFrom);
        CopyTrackData(tracks.get(), mapIndex, aFrom, aTo, &trackFinished);
        mappedTracksFinished.AppendElement(trackFinished);
        mappedTracksWithMatchingInputTracks.AppendElement(true);
      }
    }
  }
  for (int32_t i = mTrackMap.Length() - 1; i >= 0; --i) {
    if (mappedTracksFinished[i]) {
      EndTrack(i);
    } else {
      allFinished = false;
    }
    if (!mappedTracksWithMatchingInputTracks[i]) {
      for (auto listener : mTrackMap[i].mOwnedDirectListeners) {
        // Remove listeners while the entry still exists.
        RemoveDirectTrackListenerImpl(listener, mTrackMap[i].mOutputTrackID);
      }
      mTrackMap.RemoveElementAt(i);
    }
  }
  if (allFinished && mAutofinish && (aFlags & ALLOW_FINISH)) {
    // All streams have finished and won't add any more tracks, and
    // all our tracks have actually finished and been removed from our map,
    // so we're finished now.
    FinishOnGraphThread();
  }
  if (allHaveCurrentData) {
    // We can make progress if we're not blocked
    mHasCurrentData = true;
  }
}