Fixes to build, install, and run ffmpeg ssc on win32

This commit is contained in:
Ron Pedde 2006-05-28 06:11:37 +00:00
parent 0f64686356
commit 89b6af89b3
14 changed files with 323 additions and 36 deletions

View File

@ -62,12 +62,12 @@ typedef struct tag_plugin_event_fn {
} PLUGIN_EVENT_FN;
typedef struct tag_plugin_transcode_fn {
void *(*init)(void);
void (*deinit)(void*);
int (*open)(void*, char *, char*, int);
int (*close)(void*);
int (*read)(void*, char*, int);
char *(*error)(void*);
void *(*ssc_init)(void);
void (*ssc_deinit)(void*);
int (*ssc_open)(void*, char *, char*, int);
int (*ssc_close)(void*);
int (*ssc_read)(void*, char*, int);
char *(*ssc_error)(void*);
} PLUGIN_TRANSCODE_FN;
/* info for rendezvous advertising */

View File

@ -439,7 +439,7 @@ int main(int argc, char *argv[]) {
txt_add(txtrecord,"iTSh Version=131073"); /* iTunes 6.0.4 */
txt_add(txtrecord,"Version=196610"); /* iTunes 6.0.4 */
txt_add(txtrecord,"Password=%s",conf_isset("general","password") ? "true" : "false");
srand(time(NULL));
srand((unsigned int)time(NULL));
txt_add(txtrecord,"ffid=%08x",rand());
DPRINTF(E_LOG,L_MAIN|L_REND,"Registering rendezvous names\n");

View File

@ -273,7 +273,7 @@ int _plugin_error(char **pe, int error, ...) {
*/
void _plugin_recalc_codecs(void) {
PLUGIN_ENTRY *ppi;
int size=0;
size_t size=0;
_plugin_writelock();
@ -606,14 +606,14 @@ int _plugin_ssc_copy(WS_CONNINFO *pwsc, PLUGIN_TRANSCODE_FN *pfn,
if(bytes_to_read > offset)
bytes_to_read = offset;
bytes_read = pfn->read(vp,buffer,bytes_to_read);
bytes_read = pfn->ssc_read(vp,buffer,bytes_to_read);
if(bytes_read <= 0)
return bytes_read;
offset -= bytes_read;
}
while((bytes_read=pfn->read(vp,buffer,sizeof(buffer))) > 0) {
while((bytes_read=pfn->ssc_read(vp,buffer,sizeof(buffer))) > 0) {
total_bytes_read += bytes_read;
ws_writebinary(pwsc,buffer,bytes_read);
}
@ -660,9 +660,9 @@ int plugin_ssc_transcode(WS_CONNINFO *pwsc, char *file, char *codec, int duratio
DPRINTF(E_DBG,L_PLUG,"Transcoding %s with %s\n",file,
ptc->pinfo->server);
vp_ssc = pfn->init();
vp_ssc = pfn->ssc_init();
if(vp_ssc) {
if(pfn->open(vp_ssc,file,codec,duration)) {
if(pfn->ssc_open(vp_ssc,file,codec,duration)) {
/* start reading and throwing */
ws_addresponseheader(pwsc,"Content-Type","audio/wav");
ws_addresponseheader(pwsc,"Connection","Close");
@ -678,12 +678,12 @@ int plugin_ssc_transcode(WS_CONNINFO *pwsc, char *file, char *codec, int duratio
/* start reading/writing */
result = _plugin_ssc_copy(pwsc,pfn,vp_ssc,offset);
post_error = 0;
pfn->close(vp_ssc);
pfn->ssc_close(vp_ssc);
} else {
DPRINTF(E_LOG,L_PLUG,"Error opening %s for ssc: %s\n",
file,pfn->error(vp_ssc));
file,pfn->ssc_error(vp_ssc));
}
pfn->deinit(vp_ssc);
pfn->ssc_deinit(vp_ssc);
} else {
DPRINTF(E_LOG,L_PLUG,"Error initializing transcoder: %s\n",
ptc->pinfo->server);

View File

@ -45,7 +45,7 @@ typedef struct tag_ssc_handle {
int total_decoded;
int total_written;
int errno;
int errnum;
int swab;
char *error;
@ -115,7 +115,7 @@ PLUGIN_INFO _pi = {
char *ssc_ffmpeg_error(void *pv) {
SSCHANDLE *handle = (SSCHANDLE*)pv;
return ssc_ffmpeg_errors[handle->errno];
return ssc_ffmpeg_errors[handle->errnum];
}
PLUGIN_INFO *plugin_info(PLUGIN_INPUT_FN *ppi) {
@ -169,19 +169,19 @@ int ssc_ffmpeg_open(void *vp, char *file, char *codec, int duration) {
_ppi->log(E_DBG,"opening file raw\n");
handle->pCodec = avcodec_find_decoder(id);
if(!handle->pCodec) {
handle->errno = SSC_FFMPEG_E_BADCODEC;
handle->errnum = SSC_FFMPEG_E_BADCODEC;
return FALSE;
}
handle->pCodecCtx = avcodec_alloc_context();
if(avcodec_open(handle->pCodecCtx,handle->pCodec) < 0) {
handle->errno = SSC_FFMPEG_E_CODECOPEN;
handle->errnum = SSC_FFMPEG_E_CODECOPEN;
return FALSE;
}
handle->fin = fopen(file,"rb");
if(!handle->fin) {
handle->errno = SSC_FFMPEG_E_FILEOPEN;
handle->errnum = SSC_FFMPEG_E_FILEOPEN;
return FALSE;
}
@ -190,13 +190,13 @@ int ssc_ffmpeg_open(void *vp, char *file, char *codec, int duration) {
_ppi->log(E_DBG,"opening file with format\n");
if(av_open_input_file(&handle->pFmtCtx,file,handle->pFormat,0,NULL) < 0) {
handle->errno = SSC_FFMPEG_E_FILEOPEN;
handle->errnum = SSC_FFMPEG_E_FILEOPEN;
return FALSE;
}
/* find the streams */
if(av_find_stream_info(handle->pFmtCtx) < 0) {
handle->errno = SSC_FFMPEG_E_NOSTREAM;
handle->errnum = SSC_FFMPEG_E_NOSTREAM;
return FALSE;
}
@ -211,7 +211,7 @@ int ssc_ffmpeg_open(void *vp, char *file, char *codec, int duration) {
}
if(handle->audio_stream == -1) {
handle->errno = SSC_FFMPEG_E_NOAUDIO;
handle->errnum = SSC_FFMPEG_E_NOAUDIO;
return FALSE;
}
@ -219,7 +219,7 @@ int ssc_ffmpeg_open(void *vp, char *file, char *codec, int duration) {
handle->pCodec = avcodec_find_decoder(handle->pCodecCtx->codec_id);
if(!handle->pCodec) {
handle->errno = SSC_FFMPEG_E_BADCODEC;
handle->errnum = SSC_FFMPEG_E_BADCODEC;
return FALSE;
}
@ -227,7 +227,7 @@ int ssc_ffmpeg_open(void *vp, char *file, char *codec, int duration) {
handle->pCodecCtx->flags |= CODEC_FLAG_TRUNCATED;
if(avcodec_open(handle->pCodecCtx, handle->pCodec) < 0) {
handle->errno = SSC_FFMPEG_E_CODECOPEN;
handle->errnum = SSC_FFMPEG_E_CODECOPEN;
return FALSE;
}
@ -272,7 +272,7 @@ int _ssc_ffmpeg_read_frame(void *vp, char *buffer, int len) {
if(!handle->file_bytes_read) {
/* need to grab a new chunk */
handle->file_buffer_ptr = handle->file_buffer;
handle->file_bytes_read = fread(handle->file_buffer,
handle->file_bytes_read = (int)fread(handle->file_buffer,
1, sizeof(handle->file_buffer),
handle->fin);
handle->file_buffer_ptr = handle->file_buffer;

View File

@ -6,13 +6,14 @@
#include "ff-plugins.h"
/* Forwards */
PLUGIN_INFO *plugin_info(void);
PLUGIN_INFO *plugin_info(PLUGIN_INPUT_FN *ppi);
void plugin_handler(int, int, void *, int);
#define PIPE_BUFFER_SIZE 4096
/* Globals */
PLUGIN_EVENT_FN _pefn = { plugin_handler };
PLUGIN_INPUT_FN *_ppi;
PLUGIN_INFO _pi = {
PLUGIN_VERSION, /* version */
@ -22,7 +23,6 @@ PLUGIN_INFO _pi = {
NULL, /* output fns */
&_pefn, /* event fns */
NULL, /* transocde fns */
NULL, /* fns exported by ff */
NULL, /* rend info */
NULL /* codec list */
};
@ -34,9 +34,9 @@ typedef struct tag_plugin_msg {
char vp[1];
} PLUGIN_MSG;
#define infn ((PLUGIN_INPUT_FN *)(_pi.pi))
PLUGIN_INFO *plugin_info(void) {
PLUGIN_INFO *plugin_info(PLUGIN_INPUT_FN *ppi) {
_ppi = ppi;
return &_pi;
}
@ -50,7 +50,7 @@ void plugin_handler(int event_id, int intval, void *vp, int len) {
pmsg = (PLUGIN_MSG*)malloc(total_len);
if(!pmsg) {
// infn->log(E_LOG,"Malloc error in w32-event.c/plugin_handler\n");
// _ppi->log(E_LOG,"Malloc error in w32-event.c/plugin_handler\n");
return;
}

View File

@ -1,5 +1,5 @@
/*
* $id: webserver.c,v 1.39 2005/11/15 06:43:31 rpedde Exp $
* $Id$
* Webserver library
*
* Copyright (C) 2003 Ron Pedde (ron@pedde.com)

View File

@ -15,6 +15,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "w32-event", "w32-event.vcpr
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssc-ffmpeg", "ssc-ffmpeg.vcproj", "{DA27D6F4-7E9F-40CA-AC5C-480DC81A1C56}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
@ -37,6 +41,10 @@ Global
{E60F90F1-A1E5-49D8-A565-B990CA4BA860}.Debug.Build.0 = Debug|Win32
{E60F90F1-A1E5-49D8-A565-B990CA4BA860}.Release.ActiveCfg = Release|Win32
{E60F90F1-A1E5-49D8-A565-B990CA4BA860}.Release.Build.0 = Release|Win32
{DA27D6F4-7E9F-40CA-AC5C-480DC81A1C56}.Debug.ActiveCfg = Debug|Win32
{DA27D6F4-7E9F-40CA-AC5C-480DC81A1C56}.Debug.Build.0 = Debug|Win32
{DA27D6F4-7E9F-40CA-AC5C-480DC81A1C56}.Release.ActiveCfg = Release|Win32
{DA27D6F4-7E9F-40CA-AC5C-480DC81A1C56}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection

View File

@ -209,9 +209,6 @@
<File
RelativePath="..\src\smart-parser.c">
</File>
<File
RelativePath="..\src\ssc.c">
</File>
<File
RelativePath="..\src\w32-eventlog.c">
</File>
@ -247,6 +244,9 @@
<File
RelativePath="..\src\err.h">
</File>
<File
RelativePath="..\src\ff-plugins.h">
</File>
<File
RelativePath="..\src\ll.h">
</File>

View File

@ -117,10 +117,14 @@ Section "MainSection" SEC01
File "${DLL_SOURCE}\sqlite.dll"
File "${DLL_SOURCE}\sqlite3.dll"
File "${DLL_SOURCE}\zlib1.dll"
File "${DLL_SOURCE}\avutil.dll"
File "${DLL_SOURCE}\avcodec.dll"
File "${DLL_SOURCE}\avformat.dll"
SetOutPath "$2\plugins"
File "${MTD_SOURCE}\rsp.dll"
File "${MTD_SOURCE}\w32-event.dll"
File "${MTD_SOURCE}\ssc-ffmpeg.dll"
SetOutPath "$2\admin-root"
File "${ADMIN_ROOT}\thanks.html"
@ -174,7 +178,7 @@ Section "MainSection" SEC01
WriteINIStr "$2\mt-daapd.conf" "general" "mp3_dir" $3
HasConf:
WriteINIStr "$2\mt-daapd.conf" "plugins" "plugin_dir" "plugins"
WriteINIStr "$2\mt-daapd.conf" "plugins" "plugins" "rsp.dll,w32-event.dll"
WriteINIStr "$2\mt-daapd.conf" "plugins" "plugins" "rsp.dll,w32-event.dll,ssc-ffmpeg.dll"
ReadINIStr $0 "$2\mt-daapd.conf" "general" "rescan_interval"
StrCmp $0 "" rescan_set rescan_skip
rescan_set:
@ -402,8 +406,12 @@ Section Uninstall
Delete "$INSTDIR\sqlite3.dll"
Delete "$INSTDIR\mt-daapd.conf"
Delete "$INSTDIR\zlib1.dll"
Delete "$INSTDIR\avutil.dll"
Delete "$INSTDIR\avcodec.dll"
Delete "$INSTDIR\avformat.dll"
Delete "$INSTDIR\plugins\rsp.dll"
Delete "$INSTDIR\plugins\w32-event.dll"
Delete "$INSTDIR\plugins\ssc-ffmpeg.dll"
Delete "$INSTDIR\songs.db"
Delete "$INSTDIR\songs3.db"
Delete "$INSTDIR\mt-daapd-example.conf"

14
win32/ssc-ffmpeg-res.h Normal file
View File

@ -0,0 +1,14 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by ssc-ffmpeg.rc
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

4
win32/ssc-ffmpeg.def Normal file
View File

@ -0,0 +1,4 @@
LIBRARY ssc-ffmpeg
EXPORTS
plugin_info

102
win32/ssc-ffmpeg.rc.templ Normal file
View File

@ -0,0 +1,102 @@
// Microsoft Visual C++ generated resource script.
//
#include "ssc-ffmpeg-res.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"ssc-ffmpeg-res.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include "<windows.h>"\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,$WCREV$
PRODUCTVERSION 1,0,0,$WCREV$
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Firefly Media Server"
VALUE "FileDescription", "ffmpeg transcoder"
VALUE "FileVersion", "1.0 svn-$WCREV$"
VALUE "InternalName", "ssc-ffmpeg"
VALUE "LegalCopyright", "Copyright (C) 2006 Ron Pedde"
VALUE "OriginalFilename", "ssc-ffmpeg.dll"
VALUE "ProductName", "Firefly Media Server"
VALUE "ProductVersion", "1.0 svn-$WCREV$"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

149
win32/ssc-ffmpeg.vcproj Normal file
View File

@ -0,0 +1,149 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="ssc-ffmpeg"
ProjectGUID="{DA27D6F4-7E9F-40CA-AC5C-480DC81A1C56}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\win32;.;..\src"
PreprocessorDefinitions="HAVE_CONFIG_H;_WIN32"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="avcodec.lib avformat.lib avutil.lib"
OutputFile="$(OutDir)/ssc-ffmpeg.dll"
LinkIncremental="2"
ModuleDefinitionFile="ssc-ffmpeg.def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/ssc-ffmpeg.pdb"
SubSystem="2"
ImportLibrary="$(OutDir)/ssc-ffmpeg.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\win32;.;..\src"
PreprocessorDefinitions="HAVE_CONFIG_H;_WIN32"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="avcodec.lib avformat.lib avutil.lib"
OutputFile="$(OutDir)/ssc-ffmpeg.dll"
LinkIncremental="1"
ModuleDefinitionFile="ssc-ffmpeg.def"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/ssc-ffmpeg.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath="..\src\plugins\ssc-ffmpeg.c">
</File>
<File
RelativePath=".\ssc-ffmpeg.def">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\ssc-ffmpeg-res.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
<File
RelativePath=".\ssc-ffmpeg.rc">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -7,10 +7,12 @@ echo Fixing version info...
%SUBWC% %0\..\.. %0\..\config.h.templ %0\..\config.h
%SUBWC% %0\..\.. %0\..\FireflyConfig\AssemblyInfo.cs.templ %0\..\FireflyConfig\AssemblyInfo.cs
%SUBWC% %0\..\.. %0\..\nsi\mt-daapd.nsi.templ %0\..\nsi\mt-daapd.nsi
%SUBWC% %0\..\.. %0\..\ssc-ffmpeg.rc.templ %0\..\ssc-ffmpeg.rc
goto END
:NOSUBWC
copy %0\..\config.h.templ %0\..\config.h
copy %0\..\FireflyConfig\AssemblyInfo.cs.templ %0\..\FireflyConfig\AssemblyInfo.cs
copy %0\..\nsi\mt-daapd.nsi.templ %0\..\nsi\mt-daapd.nsi
copy %0\..\.. %0\..\ssc-ffmpeg.rc.templ %0\..\ssc-ffmpeg.rc
:END