view MediaPlayer.h @ 2451:0eb0826e18b3

Слияние
author Ritor1
date Fri, 25 Jul 2014 14:19:14 +0600
parents 90349b8048a5
children 5991abe37c1d
line wrap: on
line source

#pragma once
#include "OSWindow.h"
#include "Texture.h"
#include "MediaPlayer.h"

#pragma pack(push, 1)

#pragma pack(pop)

#pragma pack(push, 1)
#pragma pack(pop)



extern "C"
{
#include "lib/libavcodec/avcodec.h"
#include "lib/libavformat/avformat.h"
#include "lib/libavutil/avutil.h"
#include "lib/libavutil/imgutils.h"
#include "lib/libswscale/swscale.h"
#include "lib/libswresample/swresample.h"
#include "lib/libavutil/opt.h"
}
#pragma comment(lib, "avcodec.lib")
#pragma comment(lib, "avformat.lib")
#pragma comment(lib, "avutil.lib")
#pragma comment(lib, "swscale.lib")
#pragma comment(lib, "swresample.lib")

#include "lib/OpenAL/al.h"
#include "lib/OpenAL/alc.h"
#pragma comment(lib, "OpenAL32.lib")

#pragma pack(push, 1)

struct MovieHeader
{
  char pVideoName[40];
  unsigned int uFileOffset;
};

namespace Media
{
  class ITrack
  {
    public:
      virtual ~ITrack() {}

	  virtual void Play(bool loop = false) = 0;
      virtual void Release() = 0;
  };

  class IMovie
  {
    public: 
      virtual ~IMovie() {}

	  virtual void Play() = 0;
      virtual void GetNextFrame(double dt, void *target_surface) = 0;
      virtual void Release() = 0;

  };

  class MPlayer
  {
    public:
               MPlayer();
      virtual ~MPlayer();

	  //for video/////////////////////////////////////////////////
      RGBTexture pVideoFrame;
      int field_44;//final video
      unsigned int bFirstFrame;
      unsigned int bLoopPlaying;
      unsigned int bStopBeforeSchedule;
      OSWindow *window;
      int uMovieType;//0 - null, 1 - bik, 2 - smk
      char pCurrentMovieName[64];
      char pVideoFrameTextureFilename[32];
	  MovieHeader *pMightVideoHeaders;
      MovieHeader *pMagicVideoHeaders;
      HANDLE hMightVid;
      HANDLE hMagicVid;
      unsigned int uNumMightVideoHeaders;
      unsigned int uNumMagicVideoHeaders;
	  bool bPlaying_Movie;
      bool loop_current_file;
      DWORD time_video_begin;
      int current_movie_width;
      int current_movie_height;

      HANDLE hVidFile;
      int uSize;
      int uOffset;

      void Initialize(OSWindow *window);

      void OpenGlobalMovie(const char *pFilename, unsigned int bLoop);
      void OpenHouseMovie(const char *pMovieName, unsigned int a3_1);

	  void _4BF5B2();
      void LoadMovie(const char *);
      void SelectMovieType();

	  void GlobalMovieLoop(const char *pMovieName, int a2);
      void HouseMovieLoop();

      void ShowMM7IntroVideo_and_LoadingScreen();
      void Unload();
	  ///////////////////////////////////////////////

      IMovie *LoadMovie(const wchar_t *name, int width, int height, int cache_ms);
      IMovie *LoadMovieFromLOD(HANDLE h, int readFunction(void*, uint8_t*, int), int64_t seekFunction(void*, int64_t, int), int width, int height);


      ITrack *LoadTrack(const wchar_t *name);

  protected:
    static int readFunction(void *, uint8_t *, int);
    static int64_t seekFunction(void *, int64_t, int);
  };
};
#pragma pack(pop)
extern Media::MPlayer *pMediaPlayer;
extern Media::IMovie *pMovie_Track;
extern Media::ITrack *pAudio_Track;
extern class Movie *movie;

extern int mSourceID;

extern void PlayMovie(const wchar_t * pFilename);
extern void PlayAudio(const wchar_t * pFilename);
extern void MovieRelease();