Beispiel #1
0
void CDummyVideoPlayer::Seek(bool bPlus, bool bLargeStep, bool bChapterOverride)
{
  if (g_advancedSettings.m_videoUseTimeSeeking && GetTotalTime() > 2000*g_advancedSettings.m_videoTimeSeekForwardBig)
  {
    int seek = 0;
    if (bLargeStep)
      seek = bPlus ? g_advancedSettings.m_videoTimeSeekForwardBig : g_advancedSettings.m_videoTimeSeekBackwardBig;
    else
      seek = bPlus ? g_advancedSettings.m_videoTimeSeekForward : g_advancedSettings.m_videoTimeSeekBackward;
    // do the seek
    SeekTime(GetTime() + seek * 1000);
  }
  else
  {
    float percent = GetPercentage();
    if (bLargeStep)
      percent += bPlus ? g_advancedSettings.m_videoPercentSeekForwardBig : g_advancedSettings.m_videoPercentSeekBackwardBig;
    else
      percent += bPlus ? g_advancedSettings.m_videoPercentSeekForward : g_advancedSettings.m_videoPercentSeekBackward;

    if (percent >= 0 && percent <= 100)
    {
      // should be modified to seektime
      SeekPercentage(percent);
    }
  }
}
Beispiel #2
0
void PAPlayer::Seek(bool bPlus, bool bLargeStep, bool bChapterOverride)
{
  if (!CanSeek()) return;

  __int64 seek;
  if (g_advancedSettings.m_musicUseTimeSeeking && GetTotalTime() > 2 * g_advancedSettings.m_musicTimeSeekForwardBig)
  {
    if (bLargeStep)
      seek = bPlus ? g_advancedSettings.m_musicTimeSeekForwardBig : g_advancedSettings.m_musicTimeSeekBackwardBig;
    else
      seek = bPlus ? g_advancedSettings.m_musicTimeSeekForward : g_advancedSettings.m_musicTimeSeekBackward;
    seek *= 1000;
    seek += GetTime();
  }
  else
  {
    float percent;
    if (bLargeStep)
      percent = bPlus ? (float)g_advancedSettings.m_musicPercentSeekForwardBig : (float)g_advancedSettings.m_musicPercentSeekBackwardBig;
    else
      percent = bPlus ? (float)g_advancedSettings.m_musicPercentSeekForward : (float)g_advancedSettings.m_musicPercentSeekBackward;
    seek = (__int64)(GetTotalTime64() * (GetPercentage() + percent) / 100);
  }

  SeekTime(seek);
}
Beispiel #3
0
bool OMXReader::SeekChapter(int chapter, double* startpts)
{
	if(chapter < 1)
	{
		chapter = 1;
	}

	if(m_pFormatContext == NULL)
	{
		return false;
	}

	#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,14,0)
	if(chapter < 1 || chapter > (int)m_pFormatContext->nb_chapters)
	{
		return false;
	}

	AVChapter *ch = m_pFormatContext->chapters[chapter-1];
	double dts = ConvertTimestamp(ch->start, ch->time_base.den, ch->time_base.num);
	return SeekTime(DVD_TIME_TO_MSEC(dts), 0, startpts);
	#else
	return false;
	#endif
}
Beispiel #4
0
void PAPlayer::Seek(bool bPlus, bool bLargeStep, bool bChapterOverride)
{
  if (!CanSeek()) return;

  long long seek;
  if (g_advancedSettings.m_musicUseTimeSeeking && m_playerGUIData.m_totalTime > 2 * g_advancedSettings.m_musicTimeSeekForwardBig)
  {
    if (bLargeStep)
      seek = bPlus ? g_advancedSettings.m_musicTimeSeekForwardBig : g_advancedSettings.m_musicTimeSeekBackwardBig;
    else
      seek = bPlus ? g_advancedSettings.m_musicTimeSeekForward : g_advancedSettings.m_musicTimeSeekBackward;
    seek *= 1000;
    seek += m_playerGUIData.m_time;
  }
  else
  {
    float percent;
    if (bLargeStep)
      percent = bPlus ? (float)g_advancedSettings.m_musicPercentSeekForwardBig : (float)g_advancedSettings.m_musicPercentSeekBackwardBig;
    else
      percent = bPlus ? (float)g_advancedSettings.m_musicPercentSeekForward : (float)g_advancedSettings.m_musicPercentSeekBackward;
    seek = static_cast<long long>(GetTotalTime64() * (GetPercentage() + percent) / 100);
  }

  SeekTime(seek);
}
Beispiel #5
0
CAMRSource::CAMRSource(CMediaSource *pSource, int nIndex) : CMediaSource(pSource, nIndex)
{
	char pBuffer[5];

	SourceReadData(pBuffer, 5);
	if (strncmp(pBuffer, "#!AMR", 5) != 0)
		return;

	m_nOutputNum = 1;
	SeekTime(0);
}
Beispiel #6
0
bool CDummyVideoPlayer::OpenFile(const CFileItem& file, const CPlayerOptions &options)
{
  try
  {
    Create();
    if( options.starttime > 0 )
      SeekTime( (int64_t)(options.starttime * 1000) );
    return true;
  }
  catch(...)
  {
    CLog::Log(LOGERROR,"%s - Exception thrown on open", __FUNCTION__);
    return false;
  }
}
Beispiel #7
0
bool AudioStream::Open(const char* Filename)
{
	mSource = SourceFromExt(Filename);

	if (mSource && mSource->IsValid())
	{
		Channels = mSource->GetChannels();

		mBufferSize = BUFF_SIZE;

		mData = new short[mBufferSize];
		PaUtil_InitializeRingBuffer(&mRingBuf, sizeof(int16), mBufferSize, mData);

		mStreamTime = mPlaybackTime = 0;
		
		SeekTime(0);

		return true;
	}else
		return false;
}
int CAMLPlayer::SeekChapter(int chapter_index)
{
  CSingleLock lock(m_aml_csection);

  // chapter_index is a one based value.
  if (m_chapter_count > 1)
  {
    if (chapter_index < 0)
      chapter_index = 0;
    if (chapter_index > m_chapter_count)
      return 0;

    // time units are seconds,
    // so we add 1000ms to get into the chapter.
    int64_t seek_ms = m_chapters[chapter_index - 1]->seekto_ms + 1000;

    //  seek to 1 second and play is immediate.
    if (seek_ms <= 0)
      seek_ms = 1000;

    // seek to chapter here
    g_infoManager.SetDisplayAfterSeek(100000);
    SeekTime(seek_ms);
    m_callback.OnPlayBackSeekChapter(chapter_index);
    g_infoManager.SetDisplayAfterSeek();
  }
  else
  {
    // we do not have a chapter list so do a regular big jump.
    if (chapter_index > 0)
      Seek(true,  true);
    else
      Seek(false, true);
  }
  return 0;
}
void CAMLPlayer::Seek(bool bPlus, bool bLargeStep)
{
  // force updated to m_elapsed_ms, m_duration_ms.
  GetStatus();

  CSingleLock lock(m_aml_csection);

  // try chapter seeking first, chapter_index is ones based.
  int chapter_index = GetChapter();
  if (bLargeStep)
  {
    // seek to next chapter
    if (bPlus && (chapter_index < GetChapterCount()))
    {
      SeekChapter(chapter_index + 1);
      return;
    }
    // seek to previous chapter
    if (!bPlus && chapter_index)
    {
      SeekChapter(chapter_index - 1);
      return;
    }
  }

  int64_t seek_ms;
  if (g_advancedSettings.m_videoUseTimeSeeking)
  {
    if (bLargeStep && (GetTotalTime() > (2 * g_advancedSettings.m_videoTimeSeekForwardBig)))
      seek_ms = bPlus ? g_advancedSettings.m_videoTimeSeekForwardBig : g_advancedSettings.m_videoTimeSeekBackwardBig;
    else
      seek_ms = bPlus ? g_advancedSettings.m_videoTimeSeekForward    : g_advancedSettings.m_videoTimeSeekBackward;
    // convert to milliseconds
    seek_ms *= 1000;
    seek_ms += m_elapsed_ms;
  }
  else
  {
    float percent;
    if (bLargeStep)
      percent = bPlus ? g_advancedSettings.m_videoPercentSeekForwardBig : g_advancedSettings.m_videoPercentSeekBackwardBig;
    else
      percent = bPlus ? g_advancedSettings.m_videoPercentSeekForward    : g_advancedSettings.m_videoPercentSeekBackward;
    percent /= 100.0f;
    percent += (float)m_elapsed_ms/(float)m_duration_ms;
    // convert to milliseconds
    seek_ms = m_duration_ms * percent;
  }

  // handle stacked videos, dvdplayer does it so we do it too.
  if (g_application.CurrentFileItem().IsStack() &&
    (seek_ms > m_duration_ms || seek_ms < 0))
  {
    CLog::Log(LOGDEBUG, "CAMLPlayer::Seek: In mystery code, what did I do");
    g_application.SeekTime((seek_ms - m_elapsed_ms) * 0.001 + g_application.GetTime());
    // warning, don't access any object variables here as
    // the object may have been destroyed
    return;
  }

  if (seek_ms <= 1000)
    seek_ms = 1000;

  if (seek_ms > m_duration_ms)
    seek_ms = m_duration_ms;

  // do seek here
  g_infoManager.SetDisplayAfterSeek(100000);
  SeekTime(seek_ms);
  m_callback.OnPlayBackSeek((int)seek_ms, (int)(seek_ms - m_elapsed_ms));
  g_infoManager.SetDisplayAfterSeek();
}
Beispiel #10
0
void PAPlayer::SeekPercentage(float fPercent /*=0*/)
{
  if (fPercent < 0.0f) fPercent = 0.0f;
  if (fPercent > 100.0f) fPercent = 100.0f;
  SeekTime((__int64)(fPercent * 0.01f * (float)GetTotalTime64()));
}
Beispiel #11
0
void CDummyVideoPlayer::SeekPercentage(float iPercent)
{
  int64_t iTime = (int64_t)(GetTotalTime() * iPercent / 100);
  SeekTime(iTime);
}
Beispiel #12
0
void CUPnPPlayer::SeekPercentage(float percent)
{
  int64_t tot = GetTotalTime();
  if (tot)
    SeekTime((int64_t)(tot * percent / 100));
}
Beispiel #13
0
CMIDISource::CMIDISource(CMediaSource *pSource, int nIndex) : CMediaSource(pSource, nIndex)
{
	char str[5];
	int i;
	StreamPos *pPos;
	MIDITrack *pTrack;
	TempoEvent *pEvent;
	unsigned char pData[1024];
	int nSize;

	m_pStreamPos = NULL;
	m_pTracks = NULL;
	m_pTempoEvents = NULL;
	m_nDuration = 0;

	str[4] = '\0';
	SourceReadData(str, 4);
	if (strcmp(str, "MThd") != 0)
		return;
	if (SourceReadBigEndian(4) != 6)  //header length
		return;

	m_MIDIInfo.nFormat = SourceReadBigEndian(2);
	m_nOutputNum = SourceReadBigEndian(2);  //number of track
	m_nTicksPerQuarterNote = SourceReadBigEndian(2);
	m_pStreamPos = new StreamPos[m_nOutputNum];
	m_pTracks = new MIDITrack[m_nOutputNum];
	for (i = 0; i < m_nOutputNum; i++)
	{
		pPos = m_pStreamPos + i;
		SourceReadData(str, 4);  //track id
		pPos->nSize = SourceReadBigEndian(4);  //track length
		if (strcmp(str, "MTrk") == 0)
			pPos->nHeadPos = SourceGetPosition();
		else
			pPos->nHeadPos = 0;  //invalid track
		SourceSeekData(pPos->nSize, SEEK_CUR);  //skip to next track
	}

	if (m_nOutputNum == 0)
		return;

	pTrack = m_pTracks;  //first track;
	m_pTempoEvents = new TempoEvent[m_pStreamPos[0].nSize / 6];  //minimum size of a change tempo event is 6
	m_nTempoEventNum = 1;
	pEvent = m_pTempoEvents;
	pEvent->nTempo = 500000;  //default tempo in microseconds per quarter note
	pEvent->nTicks = 0;
	pEvent->nTime = 0;

	SeekTime(0);
	for (;;)
	{
		nSize = ReadData(0, pData, sizeof(pData));
		if (nSize == 0)
			break;

		if (pData[0] == 0xFF && pData[1] == 0x51)  //set tempo
		{
			pEvent = m_pTempoEvents + m_nTempoEventNum;
			pEvent->nTempo = (pData[2] << 16) | (pData[3] << 8) | pData[4];  //microseconds per quarter note
			pEvent->nTicks = pTrack->nTicks;
			pEvent->nTime = TicksToTime(pTrack->nTicks);
			++m_nTempoEventNum;
		}
	}

	m_nDuration = m_pStreamPos[0].nTime;
	for (i = 1; i < m_nOutputNum; i++)  //for each track except the first one
	{
		do
		{
			nSize = ReadData(i, pData, sizeof(pData));
		} while (nSize > 0);  //until the last event of this track
		if (m_pStreamPos[i].nTime > m_nDuration)
			m_nDuration = m_pStreamPos[i].nTime;
	}
	SeekTime(0);
}
Beispiel #14
0
void CDummyVideoPlayer::SeekPercentage(float iPercent)
{
  __int64 iTotalMsec = GetTotalTime() * 1000;
  __int64 iTime = (__int64)(iTotalMsec * iPercent / 100);
  SeekTime(iTime);
}