Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ============================================================================
- Name : QarvaOttBanchmark.cpp
- Author : OrionTSEP
- Version :
- Copyright : (C) Qarva LLC
- Description : Uses shared library to get data from Aqua server
- ============================================================================
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- #include "stdinc.h"
- #include "ottclient.h"
- #include "maindefs.h"
- #include "hsctime.h"
- #include "QarvaPlayerCPP.h"
- #include "logger.h"
- void GreetUser()
- {
- printf("===========================================\n");
- printf("Qarva Aqua OTT Banchmark v1.0\n");
- printf("===========================================\n");
- }
- void PrintHelp()
- {
- printf("Use: qarva-ott-banchmark <channel_id> <server_ip> <port_base> <port_count> <con_count> <try_count>\n");
- printf(" channel_id - Channel ID to test\n");
- printf(" server_ip - Server IP to test\n");
- printf(" port_base - Server base port, usually it is 12000\n");
- printf(" port_count - Server port count, usually it is 3000 (that means open port 12000-14999)\n");
- printf(" con_count - Server connection count, valid values 1-32\n\n");
- printf(" try_count - Channel change counts\n\n");
- printf("For example: qarva-ott-banchmark 225 82.113.35.116 12000 3000 8 5\n");
- printf(" (This is real server and params of Tvoyo TV)\n");
- printf("===========================================\n");
- }
- int main(int argc, char* argv[])
- {
- GreetUser();
- if (argc != 7)
- {
- PrintHelp();
- return -1;
- }
- /* Validate options */
- int nChannelID = atoi(argv[1]);
- std::string sServerIP(argv[2]);
- int nPortBase = atoi(argv[3]);
- int nPortCount = atoi(argv[4]);
- int nConCount = atoi(argv[5]);
- int nChangeCount = atoi(argv[6]);
- int nSpeed = 2;
- if ((nConCount < 1) || (nConCount > 32))
- {
- PrintHelp();
- return -1;
- }
- /* Greet user */
- HSCLoggerInit(false, false, "qarva-ott-test");
- printf("Sample is starting up...\n");
- /* Set Ports */
- printf("Setting ports...\n");
- QarvaDecoder_OptionsSetPorts(nPortBase, nPortCount);
- /* Add servers */
- printf("Adding servers...\n");
- for (int i=0; i<nConCount; i++)
- {
- QarvaDecoder_OptionsAddServer(sServerIP.c_str());
- }
- /* Create decoder */
- printf("Starting decoder...\n");
- QarvaDecoder_StartQarvaOTT();
- while(!QarvaDecoder_QarvaOTTInitialized()) sleep(1);
- QarvaDecoder_SetLowLatencyMode(false);
- uint64_t nLastCCTime = 0;
- uint64_t nTime = 0;
- printf("Processing... 10%\r");
- for(int i = 0; i < nChangeCount; i++)
- {
- QarvaDecoder_TuneToChannel(nChannelID, nTime, 0, 0);
- while(!QarvaDecoder_PESReady(true)) usleep(10000);
- uint64_t nPTS = QarvaDecoder_GetPESPTS(true);
- QarvaDecoder_UpdateVisiblePTS(nPTS);
- uint64_t nCurCCTime = QarvaDecoder_GetLastCCTime();
- nLastCCTime += nCurCCTime;
- }
- printf("Processing... 50%\r");
- uint64_t nAverageCCTime = nLastCCTime / nChangeCount;
- nTime = HSC_TimeNow();
- nTime -= 13000;
- for(int i = 0; i < nChangeCount; i++)
- {
- QarvaDecoder_TuneToChannel(nChannelID, nTime, 0, 0);
- while(!QarvaDecoder_PESReady(true)) usleep(10000);
- uint64_t nPTS = QarvaDecoder_GetPESPTS(true);
- QarvaDecoder_UpdateVisiblePTS(nPTS);
- uint64_t nCurCCTime = QarvaDecoder_GetLastCCTime();
- nLastCCTime += nCurCCTime;
- }
- uint64_t nAverageTMTime = nLastCCTime / nChangeCount;
- printf("Processing... 100%\n");
- for(int i = 0; i < nChangeCount; i++)
- {
- QarvaDecoder_SwitchToFF(nSpeed);
- while(!QarvaDecoder_PESReady(true)) usleep(10000);
- uint64_t nPTS = QarvaDecoder_GetPESPTS(true);
- QarvaDecoder_UpdateVisiblePTS(nPTS);
- uint64_t nCurCCTime = QarvaDecoder_GetLastCCTime();
- nLastCCTime += nCurCCTime;
- }
- uint64_t nAveragePBTime = nLastCCTime / nChangeCount;
- printf("Average cc banchmark is: %llu\n", nAverageCCTime);
- printf("Average timeshift banchmark is: %llu\n", nAverageTMTime);
- printf("Average playback banchmark is: %llu while speed : %d\n", nAveragePBTime, nSpeed);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement