Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Add cover extraction
  • Loading branch information
RangerCD committed Feb 21, 2016
1 parent 11c2ce5 commit a39b4e3
Show file tree
Hide file tree
Showing 174 changed files with 36,989 additions and 156 deletions.
114 changes: 0 additions & 114 deletions foo_cad/foo_cad.vcxproj

This file was deleted.

35 changes: 0 additions & 35 deletions foo_cad/foo_cad.vcxproj.filters

This file was deleted.

28 changes: 25 additions & 3 deletions foo_cad.sln → foo_cad_plus.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foo_cad", "foo_cad\foo_cad.vcxproj", "{CC272D9D-8B6A-43D0-AA2E-9F46B0D07C38}"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foo_cad_plus", "foo_cad_plus\foo_cad_plus.vcxproj", "{CC272D9D-8B6A-43D0-AA2E-9F46B0D07C38}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_component_client", "..\foobar2000_component_client\foobar2000_component_client.vcxproj", "{71AD2674-065B-48F5-B8B0-E1F9D3892081}"
EndProject
Expand All @@ -14,29 +16,49 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CC272D9D-8B6A-43D0-AA2E-9F46B0D07C38}.Debug|Win32.ActiveCfg = Debug|Win32
{CC272D9D-8B6A-43D0-AA2E-9F46B0D07C38}.Debug|Win32.Build.0 = Debug|Win32
{CC272D9D-8B6A-43D0-AA2E-9F46B0D07C38}.Debug|x64.ActiveCfg = Debug|Win32
{CC272D9D-8B6A-43D0-AA2E-9F46B0D07C38}.Release|Win32.ActiveCfg = Release|Win32
{CC272D9D-8B6A-43D0-AA2E-9F46B0D07C38}.Release|Win32.Build.0 = Release|Win32
{CC272D9D-8B6A-43D0-AA2E-9F46B0D07C38}.Release|x64.ActiveCfg = Release|Win32
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|Win32.ActiveCfg = Debug|Win32
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|Win32.Build.0 = Debug|Win32
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|x64.ActiveCfg = Debug|x64
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|x64.Build.0 = Debug|x64
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|Win32.ActiveCfg = Release|Win32
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|Win32.Build.0 = Release|Win32
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|x64.ActiveCfg = Release|x64
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|x64.Build.0 = Release|x64
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|Win32.ActiveCfg = Debug|Win32
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|Win32.Build.0 = Debug|Win32
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|x64.ActiveCfg = Debug|x64
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|x64.Build.0 = Debug|x64
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|Win32.ActiveCfg = Release|Win32
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|Win32.Build.0 = Release|Win32
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|x64.ActiveCfg = Release|x64
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|x64.Build.0 = Release|x64
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|Win32.ActiveCfg = Debug|Win32
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|Win32.Build.0 = Debug|Win32
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|x64.ActiveCfg = Debug|x64
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|x64.Build.0 = Debug|x64
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|Win32.ActiveCfg = Release|Win32
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|Win32.Build.0 = Release|Win32
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|x64.ActiveCfg = Release|x64
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|x64.Build.0 = Release|x64
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|Win32.ActiveCfg = Debug|Win32
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|Win32.Build.0 = Debug|Win32
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|x64.ActiveCfg = Debug|x64
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|x64.Build.0 = Debug|x64
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|Win32.ActiveCfg = Release|Win32
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|Win32.Build.0 = Release|Win32
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|x64.ActiveCfg = Release|x64
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
58 changes: 54 additions & 4 deletions foo_cad/Plugin.cpp → foo_cad_plus/Plugin.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright (C) 2012 Birunthan Mohanathas <http://poiru.net>
2015 RangerCD <http://www.debug.moe>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
Expand All @@ -19,6 +20,12 @@
#include "cad_sdk.h"
#include "Plugin.h"

#include "PlusMsg.h"
#include "PlusCover.h"
#include <string>

using namespace std;

const GUID ORDER_DEFAULT = { 0xBFC61179, 0x49AD, 0x4E95, { 0x8D, 0x60, 0xA2, 0x27, 0x06, 0x48, 0x55, 0x05 } }; // {BFC61179-49AD-4E95-8D60-A22706485505}
const GUID ORDER_REPEAT = { 0x4BF4B280, 0x0BB4, 0x4DD0, { 0x8E, 0x84, 0x37, 0xC3, 0x20, 0x9C, 0x3D, 0xA2 } }; // {4BF4B280-0BB4-4DD0-8E84-37C3209C3DA2}
const GUID ORDER_REPEAT_PLAYLIST = { 0x681CC6EA, 0x60AE, 0x4BF9, { 0x91, 0x3B, 0xBB, 0x5F, 0x4E, 0x86, 0x4F, 0x2A } }; // {681CC6EA-60AE-4BF9-913B-BB5F4E864F2A}
Expand All @@ -29,20 +36,24 @@ const GUID ORDER_SHUFFLE_ALBUMS = { 0x499E0B08, 0xC887, 0x48C1, { 0x9C, 0xCA, 0x
const GUID ORDER_SHUFFLE_DIRECTORIES = { 0x83C37600, 0xD725, 0x4727, { 0xB5, 0x3C, 0xBD, 0xEF, 0xFE, 0x5F, 0x8D, 0xC7 } }; // {83C37600-D725-4727-B53C-BDEFFE5F8DC7}

DECLARE_COMPONENT_VERSION(
"CD Art Display",
"1.0.3",
"© 2013 - Birunthan Mohanathas");
"CD Art Display Plus",
"1.1.0",
"? 2013 - Birunthan Mohanathas, 2015 - RangerCD");

static initquit_factory_t<foo_cad> foo_interface;

foo_cad::foo_cad() :
m_window(),
m_cad_window()
m_cad_window(),
//Plus
m_pCover(NULL),
m_bCoverRequired(false)
{
}

foo_cad::~foo_cad()
{
if (m_pCover) delete m_pCover;
}

void foo_cad::on_init()
Expand Down Expand Up @@ -162,6 +173,33 @@ void foo_cad::on_playback_new_track(metadb_handle_ptr track)
WCHAR buffer[2048];
int len = MultiByteToWideChar(CP_UTF8, 0, format.get_ptr(), format.get_length() + 1, buffer, _countof(buffer));

if (m_bCoverRequired)
{
if (!m_pCover) m_pCover = new PlusCover();
WCHAR * p1 = buffer, *p2 = buffer;
unsigned int index = 8;
while ((p1 = wcschr(p2, L'\t')) != nullptr && index--)p2 = p1 + 1;

wstring str;
str.assign(p2, p1 - p2);

if (m_strFilePath != str)
{
m_strFilePath = str;
str = m_pCover->GetCover(str);

if (str.length() && _countof(buffer) >= len + str.length())
{
index = 2;
while ((p1 = wcschr(p2, L'\t')) != nullptr && index--)p2 = p1 + 1;

wstring temp = str + p1;
wcscpy(p1, temp.c_str());
len += str.length();
}
}
}

COPYDATASTRUCT cds;
cds.dwData = PM_TRACKDATA;
cds.cbData = len * sizeof(WCHAR);
Expand Down Expand Up @@ -386,6 +424,18 @@ LRESULT CALLBACK foo_cad::window_proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA

return 1;
}
case PlusMsg::PlusMsg_SetAttribute:
{
switch (wParam)
{
case PlusAttr::PlusAttr_CoverNotRequired:
foo_interface.get_static_instance().m_bCoverRequired = false;
return 1;
case PlusAttr::PlusAttr_CoverRequired:
foo_interface.get_static_instance().m_bCoverRequired = true;
return 1;
}
}
}

return 0;
Expand Down
8 changes: 8 additions & 0 deletions foo_cad/Plugin.h → foo_cad_plus/Plugin.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright (C) 2012 Birunthan Mohanathas <http://poiru.net>
2015 RangerCD <http://www.debug.moe>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
Expand All @@ -19,6 +20,7 @@
#define FOOCAD_PLUGIN_H_

#include "../../SDK/foobar2000.h"
#include "PlusCover.h"

class foo_cad :
public initquit,
Expand Down Expand Up @@ -50,6 +52,12 @@ class foo_cad :

HWND m_window;
HWND m_cad_window;

//Plus
std::wstring m_strFilePath;
PlusCover * m_pCover;

bool m_bCoverRequired;
};

#endif
File renamed without changes.
47 changes: 47 additions & 0 deletions foo_cad_plus/PlusCover.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "PlusCover.h"
#include "Cover.h"

using namespace std;

PlusCover::PlusCover()
{
WCHAR buffer[MAX_PATH];
GetTempPath(MAX_PATH, buffer);
GetTempFileName(buffer, L"jpg", 0, buffer);
m_TempPath = buffer;
m_TempPath = m_TempPath.substr(0, m_TempPath.rfind(L'.') + 1) + L"jpg";
MoveFile(buffer, m_TempPath.c_str());
}

PlusCover::~PlusCover()
{
DeleteFile(m_TempPath.c_str());
}

wstring PlusCover::GetCover(wstring FilePath)
{
if (!GenCover(FilePath))
if (!SearchCover(FilePath))
return wstring();
return m_TempPath;
}

unsigned int PlusCover::GenCover(wstring FilePath)
{
TagLib::FileRef fr(FilePath.c_str(), false);
if (!fr.isNull() && CCover::GetEmbedded(fr, m_TempPath))
{
return m_TempPath.length();
}
else
{
return 0;
}
return 0;
}

bool PlusCover::SearchCover(wstring FilePath)
{
wstring folder = FilePath.substr(0, FilePath.rfind(L"\\") + 1);
return CCover::GetLocal(L"cover", folder, m_TempPath);
}
Loading

0 comments on commit a39b4e3

Please sign in to comment.