⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asfinterface.c

📁 瑞星微公司RK27XX系列芯片的SDK开发包
💻 C
字号:
/******************************************************************/
/*  Copyright (C) 2007 ROCK-CHIPS FUZHOU . All Rights Reserved.  */
/*******************************************************************
File :  AsfInterface.c
Desc :  主界面窗口
Author :
Date :  2008-01-11
Notes :
$Log :
*********************************************************************/
#include "include.h"
#include "system.h"
#include "../browser/BrowserStruct.h"
#ifdef BOARD
#include "Asffile.h"
#include "BrowserGlobal.h"
#include "AsfMacro.h"
#include "AsfVideoControl.h"
#include "../VideoCodecs/VideoCodecs.h"
#include "VideoWin.h"
#endif

/*********************************declare********************************/
#ifdef BOARD
extern SYS_FILE_INFO     VideoFileInfo;
#endif


extern int AsfAudioCtrl(int cmd);

extern int stopFillBuf;
int asfForceExit;
/*************************************************************/

/*****************************************************************/

// return value:
//     TRUE = successfully parse the file .
//     FALSE = file is not supported.
int AsfInit(video_interface_t *this, char *path)
{
    int err;

#if 1 // just debug.
    char pathName[FS_MAX_PATH_LEN];
    path = pathName;
    RKmemcpy(path, VideoFileInfo.Path, FS_MAX_PATH_LEN);
    RKstrcat(path, VideoFileInfo.Name);
#endif
    asfForceExit = FALSE;

    err = AsfFileInit(path);

    if (err == ASF_FILE_PARSING_OK)
    {
        this->audio_flag = 1;
    }
    else if (err == ASF_FILE_AUDIO_CODEC_ERR)
    {
        this->audio_flag = 0;
    }
    else
    {
        return FALSE;
    }

    return TRUE;
}

// return value:
//     TRUE = successfully open codec.
//     FALSE = codec error.
int AsfDecOpen(video_interface_t *this)
{
    if (this->audio_flag)
        this->audio_flag = AsfAudioCtrl(ASF_AUDIO_CTRL_START);  //start audio

    /* start video decoder */
    if (AsfVideoDecInit())
    {
        return FALSE;
    }

    /* start fill buffer */
    stopFillBuf = 0;
    RockOSSendMsg(MBVIDEO, AS_GUVI_VideoFillBuf, NULL);

    return TRUE;
}

int AsfFillBuf(video_interface_t *this, void *arg)
{
    int err;
    if (err = AsfFillBitStream())
        return err;

    if (!stopFillBuf)
    {
        if (RockOSSendMsg(MBVIDEO, AS_GUVI_VideoFillBuf, NULL))
            stopFillBuf = TRUE;
    }
    return 0;
}

static __inline int AsfCheckMsg(void)
{
    if (stopFillBuf)
    {
        stopFillBuf = FALSE;
        RockOSSendMsg(MBVIDEO, AS_GUVI_VideoFillBuf, NULL);
    }
}

int AsfControl(video_interface_t *this, int cmd, void *arg0, void *arg1)
{
    switch (cmd)
    {
        case VIDEO_CTRL_PLAY_PAUSE:
            if (AsfPlayPause())
            {
                if (this->audio_flag)
                {
                    AsfAudioCtrl(ASF_AUDIO_CTRL_PAUSE);
                }
                return TRUE;
            }
            else
            {
                if (this->audio_flag)
                {
                    AsfAudioCtrl(ASF_AUDIO_CTRL_RESUME);
                }
                return FALSE;
            }
            break;
#if 1
        case VIDEO_CTRL_FFD:
            if (AsfFFD(NULL) != 0)
            {
                //this->control(this, VIDEO_CTRL_RESUME, NULL, NULL);
                asfForceExit = TRUE;
                return -1;
            }
            else
            {
                if (this->audio_flag)
                    AsfAudioCtrl(ASF_AUDIO_CTRL_FFD);
                return 0;
            }
            break;

        case VIDEO_CTRL_FFW:
            if (this->audio_flag)
                AsfAudioCtrl(ASF_AUDIO_CTRL_FFW);
            return AsfFFW(NULL);
        case VIDEO_CTRL_RESUME:
            AsfResume();
            if ((this->audio_flag))
            {
                AsfAudioCtrl(ASF_AUDIO_CTRL_RESUME);
            }
            AsfCheckMsg();
            break;
#endif
        case VIDEO_CTRL_GET_CUR_TIME:
            *(unsigned int *)arg0 = AsfGetCurTime();
            break;

        case VIDEO_CTRL_GET_TOTAL_TIME:
            *(unsigned int *)arg0 = AsfGetTotalTime();
            break;

        case VIDEO_CTRL_GET_YUV_INFO:
            return AsfGetYuvAddr((char **)arg0);
            break;

        case VIDEO_CTRL_GET_RESOLUTION:
            return AsfGetResolution(arg0, arg1);
            break;

        default:
            break;
    }
    return 0;
}

int AsfSeekTime(video_interface_t *this, long time)
{
    int err;

    err = AsfVideoSeek(time);

    return err;
}

int AsfExit(video_interface_t *this, int force_exit)
{
    stopFillBuf = 1;
    if ((!force_exit) && (!asfForceExit))
    {
        /* ensure all video frames is showed out. */
        while (!AsfIsLastFrame());
    }

    /* stop audio */
    AsfAudioCtrl(ASF_AUDIO_CTRL_STOP);
    /* stop video */
    AsfDecExit();
    return 0;
}

int AsfInstallSubtitlePlugin(video_interface_t *this, subtitle_plugin_t *subtitle)
{
    return 0;
}

#ifdef TVOUT_PANEL
int Asftvout()
{
    AsfTVoutChange();
    return 0;
}
#endif

video_interface_t video_interface_wmv =
{
    "WMVASF",
    0, //audio flag
    AsfInit,
    AsfDecOpen,
    AsfFillBuf,
    AsfSeekTime,
    AsfControl,
    AsfExit,
#ifdef TVOUT_PANEL
    AsfInstallSubtitlePlugin,
    Asftvout
#else
    AsfInstallSubtitlePlugin
#endif
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -