Exemplo n.º 1
0
VideoPlayer::~VideoPlayer()
{
    LOG_START();
    free(mPath);
    pthread_mutex_destroy(&mRenderMutex);
    LOG_END();
}
bool LocalHttpServer::register_log_file(std::tstring str_path)
{
	//log注册及log线程启动
	std::tstring str_file = str_path;
	std::string log_path;
	if (!str_file.empty())
	{
		//检查目录
#ifdef WIN32
		if (str_file[str_file.size()-1] != _T('\\'))
		{
			str_file += _T("\\");
		}	
#else
		if (str_file[str_file.size()-1] != '/')
		{
			str_file += "/";
		}	
		fprintf(stderr, "log_path is:%s\n", str_file.c_str());
#endif
		//不存在则创建目录
		try
		{
			if(!SH_filesystem::dir_exist(str_file))
			{
				if (!SH_filesystem::create_dir(str_file))
				{
					return false;
				}	
			}
		}
		catch (...)
		{
			return false;
		}
		log_path = w2b(str_file) + "SHP2PSystem.log";
	}
	else
	{
#ifndef WIN32
		fprintf(stderr, "log_path is empty\n");
#endif
		log_path = "SHP2PSystem.log";
	}

	LOG_INIT_AS_FILE(log_path, false);
	LOG_START();

	LOG_FILE_REG(LOCAL_SERVER_LOG, log_path);

#ifdef WIN32
	LOG_REG(LOCAL_SERVER_LOG, LogStream::dbgv);
#else
	LOG_REG(LOCAL_SERVER_LOG, LogStream::con);
#endif

	return true;
}
Exemplo n.º 3
0
void VideoPlayer::pause(bool _pause)
{
    LOG_START();
    if (mStop) {
        return;
    }
    mPause = _pause;
    LOG_END();
}
Exemplo n.º 4
0
//static
void * VideoPlayer::doTimeCounter(void *args)
{
    LOG_START();
    VideoPlayer *player = static_cast<VideoPlayer*>(args);
    
    while(! player->mStop) {
        int base = (int)(24.0 / player->mTimeScale);
        if (player->mTimeBase % base == 0) {
            player->doUpdatePicture(player);
        }
        usleep(1000000 / 600);
        player->mTimeBase = (player->mTimeBase + 1) % 600;
    }
    
    LOG_END();
    
    return nullptr;
}
Exemplo n.º 5
0
bool RabidEngine::OnInitialize(int argc, char** argv)
{
  LOG_START("rabid_log.html");

  g_fileSystem = (IFileSystem*)new FileSystem();
  g_fileSystem->AddPath();

  g_defMgr = new DefMgr();

  g_cvarSystem = new CVarSystem();
  g_cvarSystem->Initialize();
  CVar::RegisterStaticCVars();

  g_console = new Console();
  g_console->SetScreenDimensions(GetWidth(), GetHeight());

  g_commandSystem = new CommandSystem();
  g_commandSystem->Initialize();

  g_common = new Common();

  g_renderer = CreateRenderer("GL");
  g_renderer->SetViewport(0,0, GetWidth(), GetHeight());

  g_common->Print("\x009### Rabid Hardware Radiosity Engine");
  g_common->Print("\x009### Based on the Catharsis Game Engine");
  g_common->Print("\x009### Christopher Olsen");
  g_common->Print("\x005### \x007SPACE\x005 distributes light ###");
  g_common->Print("\x005### \x007TAB\x005 switches light view modes ###");
  g_common->Print("\x005### \x007""B\x005 toggles the brightest surface ###");

  LoadMap("test.map");

  cl_camrotx.SetFloat(0.0);
  cl_camroty.SetFloat(0.0);
  cl_camrotz.SetFloat(0.0);

  logo = g_materialSystem->GetMaterial("logo");

  return true;
}
Exemplo n.º 6
0
void VideoPlayer::stop()
{
    LOG_START();
    
    if (mStop) {
        return;
    }
    
    mStop = true;
    mPictureRingBuffer.notifyRingBufferExit();
    mPictureRingBuffer.flush();
    pthread_join(mDcoderThread, nullptr);
    pthread_join(mRenderThread, nullptr);
    
    sws_freeContext(mImageConvertCtx);
    av_frame_free(&mFrame);
    avcodec_close(mCodecCtx);
    avformat_close_input(&mFormatCtx);
    
    LOG_END();
}
Exemplo n.º 7
0
VideoPlayer::VideoPlayer()
: mStop(true),
mPause(false),
mSeek(false),
mAccurateSeek(false),
mFormatCtx(nullptr),
mCodecCtx(nullptr),
mFrame(nullptr),
mVideoStreamIndex(-1),
mImageConvertCtx(nullptr),
mWidth(0),
mHeight(0),
mTimeScale(1.0),
mVideoEndCallback(nullptr),
mPicture(nullptr),
mTimeBase(0),
mFPS(0)
{
    LOG_START();
    pthread_mutex_init(&mRenderMutex, nullptr);
    LOG_END();
}
Exemplo n.º 8
0
void VideoPlayer::start()
{
    LOG_START();
    
    if (! mStop) {
        return;
    }
    
    mStop = false;
    mTimeScale = 1.0;
    av_register_all();
    
    mFilePath = CCFileUtils::sharedFileUtils()->fullPathForFilename(mPath);
    vLOGE("file path: %s\n", mFilePath.c_str());
    
    if (avformat_open_input(&mFormatCtx, mFilePath.c_str(), nullptr, nullptr) != 0) {
        vLOGE("avformat_open_input failed.\n");
        return;
    }
    
    if (avformat_find_stream_info(mFormatCtx, nullptr) < 0) {
        vLOGE("avformat_find_stream_info failed.\n");
        return;
    }
    
    for (int i = 0; i < mFormatCtx->nb_streams; i ++) {
        if (mVideoStreamIndex == -1 && mFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
            mVideoStreamIndex = i;
            break;
        }
    }
    
    vLOGE("video stream index: %d\n", mVideoStreamIndex);
    
    if (mVideoStreamIndex == -1) {
        return;
    }
    
    if (mWidth <= 0) {
        mWidth = mFormatCtx->streams[mVideoStreamIndex]->codec->width;
    }
    
    if (mHeight <= 0) {
        mHeight = mFormatCtx->streams[mVideoStreamIndex]->codec->height;
    }
    
    vLOGE("width: %d height: %d\n", mWidth, mHeight);
    mCodecCtx = mFormatCtx->streams[mVideoStreamIndex]->codec;
    mCodecCtx->thread_count = 4;
    
    AVCodec *codec = avcodec_find_decoder(mCodecCtx->codec_id);
    if (codec == nullptr) {
        vLOGE("avcodec_find_decoder failed.\n");
        return;
    }
    
    if (avcodec_open2(mCodecCtx, codec, nullptr) != 0) {
        vLOGE("avcodec_open2 failed.\n");
        return;
    }
    
    if ((mFrame = av_frame_alloc()) == nullptr) {
        vLOGE("av_frame_alloc failed.\n");
    }
    
    mImageConvertCtx = sws_alloc_context();
    if (mImageConvertCtx == nullptr) {
        vLOGE("sws_alloc_context failed.\n");
        return;
    }
    sws_init_context(mImageConvertCtx, nullptr, nullptr);
    mImageConvertCtx = sws_getContext(mCodecCtx->width,
                                      mCodecCtx->height,
                                      mCodecCtx->pix_fmt,
                                      mWidth,
                                      mHeight,
                                      PIX_FMT_RGB24,
                                      SWS_FAST_BILINEAR, NULL, NULL, NULL);
    
    const CCSize& size = CCDirector::getInstance()->getWinSize();
    setPosition(Vec2(size.width, size.height));
    
    pthread_create(&mDcoderThread, nullptr, doProcessVideo, this);
    pthread_create(&mRenderThread, nullptr, doTimeCounter, this);

    LOG_END();
}
// Service "main" function
void _ServiceMain( void* )
{
	ThreadBag *pBag = NULL;
	//HANDLE hEvent;
	int tryTimes = 0;
	DWORD Current = 0;
	DWORD Previous = 0;
	LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\__gingko_pipe_server"); 
	DWORD dwWaitRet = WaitForMultipleObjects(2, g_hServiceEvents, FALSE, 10000);
	LOG_START();
	if( GkoInitialize() == FALSE )
	{
		return;
	}

	InitCheapman();

	LOG(L"GkCryptoInitialize\n");
	//InstallAndLoadDriver();
	LOG(L"InstallAndLoadDriver\n");

	//StartGingkoService();

	//StartGingkoHookingBackendThread();

	//GingkoOneProcess( 1256, 0 );

	//hEvent = CreateEvent( NULL, FALSE, FALSE, NULL );

	//if( hEvent == NULL || hEvent == INVALID_HANDLE_VALUE )
	//{
	//	LOG(L"Error to CreateEvent. Error Code: %d.\n", GetLastError());
	//}

	PipeListenerServerThreadStart();

	if( DriverLoad() != ERROR_SUCCESS )
	{
		PipeListenerServerThreadStop();
		GkoUnInitialize();
		UninitCheapman();
		ServiceStatus.dwCurrentState = SERVICE_STOPPED;
		SetServiceStatus( ServiceStatusHandle, &ServiceStatus );
		return;
	}

	StartThread(DeviceIoThreadProc, NULL, &pBag );

	if( pBag == NULL )
	{
		LOG(L"Error to Start DeviceIoThreadProc. Error Code: %d.\n", GetLastError());
	}

	while (dwWaitRet != WAIT_OBJECT_0)	//do until receive a STOP events
	{
		dwWaitRet = WaitForMultipleObjects(2, g_hServiceEvents, FALSE, 2000000);
		if (dwWaitRet == WAIT_OBJECT_0 + 1)	// Receive PAUSE events
		{
			WaitForSingleObject( g_hServiceEvents[2], INFINITE); // Wait for CONTINUE events
		}

		//LOG(L"CALL PING\n");
		Current = GetTickCount();
		if( Previous == 0 )
		{
			Previous = GetTickCount();
		}

		if( Current - Previous > 10000 )
		{
			Previous = Current;
			if( TRUE )
			{
				tryTimes ++;
			}

			if( tryTimes > 10 )
			{
				tryTimes = 0;
			}
		}
	}

	//SERVICE_STATUS ServiceStatus = {0};
	ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
	SetServiceStatus( ServiceStatusHandle, &ServiceStatus );
	LOG(_T("Service stop pending\n") );
	LOG(_T("Service stop pending\n") );
	UninitCheapman();

	StopThread( pBag );

	LOG(_T("Service stop pending\n") );
	PipeListenerServerThreadStop();

	//SetEvent( hEvent ); ///Exit the server thread.

	// Let's delete itself, after the service stopped
	//DeleteSvc();
	LOG(_T("Close the Service Event Handle\n") );
	CloseHandle( g_hServiceEvents[0] );
	CloseHandle( g_hServiceEvents[1] );
	CloseHandle( g_hServiceEvents[2] );

	LOG(_T("Unload Driver\n") );
	CloseBluefishDriver();
	DriverUnload();
	LOG(_T("Uninitialize Gingko System.\n") );
	GkoUnInitialize();
	
	LOG(_T("Shutdown LOG\n") );
	LOG_SHUTDOWN();

	ServiceStatus.dwCurrentState = SERVICE_STOPPED;
	SetServiceStatus( ServiceStatusHandle, &ServiceStatus );
}