blob: 86f08953f8d30b1d48b5b8e104164dd43504d2e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/**
* ======================== legal notice ======================
*
* File: FScanTest.cc
* Created: 02.07.2012, 16:57:48
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: cmps - the backend (server) part of compound media player
*
* CMP - compound media player
*
* is a client/server mediaplayer intended to play any media from any workstation
* without the need to export or mount shares. cmps is an easy to use backend
* with a (ready to use) HTML-interface. Additionally the backend supports
* authentication via HTTP-digest authorization.
* cmpc is a client with vdr-like osd-menues.
*
* Copyright (c) 2012 Reinhard Mantey, some rights reserved!
* published under Creative Commons by-sa
* For details see http://creativecommons.org/licenses/by-sa/3.0/
*
* The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
*
* --------------------------------------------------------------
*/
#include <stdlib.h>
#include <iostream>
#include <Audio.h>
#include <Movie.h>
#include <Picture.h>
#include <FilesystemScanner.h>
#include <MediaFactory.h>
#include <TimeMs.h>
class FScanTest {
public:
static void test1(void);
static void test2(void);
static void test3(void);
static void test4(void);
};
void FScanTest::test1()
{
std::cout << "FScanTest test 1" << std::endl;
for (SupportedExtension *se = cAudio::knownExtensions; se && se->extension; ++se) {
std::cout << "Audio: known extension \"" << se->extension << "\" has type: " << se->mimeType << std::endl;
}
}
void FScanTest::test2()
{
std::cout << "FScanTest test 2" << std::endl;
for (SupportedExtension *se = cMovie::knownExtensions; se && se->extension; ++se) {
std::cout << "Video: known extension \"" << se->extension << "\" has type: " << se->mimeType << std::endl;
}
}
void FScanTest::test3()
{
std::cout << "FScanTest test 3" << std::endl;
for (SupportedExtension *se = cPicture::knownExtensions; se && se->extension; ++se) {
std::cout << "Picture: known extension \"" << se->extension << "\" has type: " << se->mimeType << std::endl;
}
}
void FScanTest::test4()
///< result from java pendant: FSScanner - scanning of 9970 media took 46 ms
///< own result: found 9970 media, in 58 ms.
///< file server (mostly recordings) found 2828 media, in 53525 ms.
///< file server (added 18G audio) found 5698 media, in 44653 ms.
///< file server (same files, fresh reboot) found 5698 media, in 54723 ms.
{
cFilesystemScanner scanner;
cAbstractMedia *media;
std::cout << "FScanTest test 4" << std::endl;
scanner.SetMediaFactory(new cMediaFactory("/media"));
uint64_t start = cTimeMs::Now();
scanner.Refresh();
uint64_t end = cTimeMs::Now();
for (size_t i=0; i < scanner.MediaPool().size(); ++i) {
media = (cAbstractMedia *) scanner.MediaPool()[i];
std::cout << media->Name() << " [" << media->MimeType() << "] => " << media->LogicalPath() << std::endl;
}
std::cout << std::endl << "found " << scanner.MediaPool().size() << " media, in " << end - start << " ms." << std::endl;
const char *file2Search = "/pretty/unsupported/media/file/in/any/workstation.unknown";
// search (worst case)
start = cTimeMs::Now();
media = scanner.FindMedia(file2Search);
end = cTimeMs::Now();
std::cout << "array search took " << end - start << " ms." << std::endl;
}
int main(int argc, char** argv)
{
uint64_t t0 = cTimeMs::Now();
std::cout << "%SUITE_STARTING% FScanTest" << std::endl;
std::cout << "%SUITE_STARTED%" << std::endl;
std::cout << "%TEST_STARTED% test1 (FScanTest)" << std::endl;
uint64_t start = cTimeMs::Now();
FScanTest::test1();
uint64_t end = cTimeMs::Now();
std::cout << "%TEST_FINISHED% time=" << (double)(end - start) / 1000 << " test1 (FScanTest)" << std::endl;
std::cout << "%TEST_STARTED% test2 (FScanTest)" << std::endl;
start = cTimeMs::Now();
FScanTest::test2();
end = cTimeMs::Now();
std::cout << "%TEST_FINISHED% time=" << (double)(end - start) / 1000 << " test2 (FScanTest)" << std::endl;
std::cout << "%TEST_STARTED% test3 (FScanTest)" << std::endl;
start = cTimeMs::Now();
FScanTest::test3();
end = cTimeMs::Now();
std::cout << "%TEST_FINISHED% time=" << (double)(end - start) / 1000 << " test3 (FScanTest)" << std::endl;
std::cout << "%TEST_STARTED% test4 (FScanTest)" << std::endl;
start = cTimeMs::Now();
FScanTest::test4();
end = cTimeMs::Now();
std::cout << "%TEST_FINISHED% time=" << (double)(end - start) / 1000 << " test4 (FScanTest)" << std::endl;
std::cout << "%SUITE_FINISHED% time=" << (double)(cTimeMs::Now() - t0) / 1000 << std::endl;
return (EXIT_SUCCESS);
}
|