MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / main

Function main

framework/data_source/cache/cachedSourceTest.cpp:15–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#define SLICE_SIZE 1024*32
14
15int main()
16{
17 setProperty("ro.SliceManager.capacityM", "20"); //M
18 setProperty("ro.SliceManager.sliceSizeK", "32"); //K
19 auto *source = new cachedSource("http://player.alicdn.com/video/aliyunmedia.mp4", 10000);
20 auto *pSliceManager = ISliceManager::getManager();
21 source->setSliceManager(pSliceManager);
22 SourceConfig config{};
23 config.low_speed_time = 5;
24 config.low_speed_limit = 1;
25 source->getDataSource()->Set_config(config);
26 int ret = source->Open(0);
27
28 if (ret < 0) {
29 AF_LOGE("source open error\n");
30 return ret;
31 }
32
33 auto *sd = new cachedSource::describer(*source);
34 void *buffer = malloc(SLICE_SIZE);
35
36 do {
37 ret = sd->read(buffer, SLICE_SIZE);
38 AF_LOGD("read size is %d\n", ret);
39 } while (ret > 0);
40
41 sd->seek(0, SEEK_SET);
42 unlink("9e09053de13f4fffdf83fea670a854cb.mp4");
43 int fd = ::open("9e09053de13f4fffdf83fea670a854cb.mp4", O_CREAT | O_WRONLY, 0666);
44
45 do {
46 ret = sd->read(buffer, SLICE_SIZE);
47 AF_LOGD("read size is %d\n", ret);
48
49 if (ret > 0) {
50 ::write(fd, buffer, ret);
51 }
52 } while (ret > 0);
53
54 ::close(fd);
55 free(buffer);
56 source->Close();
57 delete source;
58 delete pSliceManager;
59 return 0;
60}
61

Callers

nothing calls this directly

Calls 8

setPropertyFunction · 0.85
setSliceManagerMethod · 0.80
Set_configMethod · 0.80
getDataSourceMethod · 0.45
OpenMethod · 0.45
readMethod · 0.45
seekMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected