Advertisement
Guest User

Untitled

a guest
May 5th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  ============================================================================
  3.  Name        : QarvaOttBanchmark.cpp
  4.  Author      : OrionTSEP
  5.  Version     :
  6.  Copyright   : (C) Qarva LLC
  7.  Description : Uses shared library to get data from Aqua server
  8.  ============================================================================
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <stdint.h>
  14.  
  15. #include "stdinc.h"
  16. #include "ottclient.h"
  17. #include "maindefs.h"
  18. #include "hsctime.h"
  19. #include "QarvaPlayerCPP.h"
  20. #include "logger.h"
  21.  
  22. void GreetUser()
  23. {
  24.     printf("===========================================\n");
  25.     printf("Qarva Aqua OTT Banchmark v1.0\n");
  26.     printf("===========================================\n");
  27. }
  28.  
  29. void PrintHelp()
  30. {
  31.     printf("Use: qarva-ott-banchmark <channel_id> <server_ip> <port_base> <port_count> <con_count> <try_count>\n");
  32.     printf("    channel_id  - Channel ID to test\n");
  33.     printf("    server_ip   - Server IP to test\n");
  34.     printf("    port_base   - Server base port, usually it is 12000\n");
  35.     printf("    port_count  - Server port count, usually it is 3000 (that means open port 12000-14999)\n");
  36.     printf("    con_count   - Server connection count, valid values 1-32\n\n");
  37.     printf("    try_count   - Channel change counts\n\n");
  38.     printf("For example: qarva-ott-banchmark 225 82.113.35.116 12000 3000 8 5\n");
  39.     printf("             (This is real server and params of Tvoyo TV)\n");
  40.     printf("===========================================\n");
  41. }
  42.  
  43. int main(int argc, char* argv[])
  44. {
  45.     GreetUser();
  46.  
  47.     if (argc != 7)
  48.     {
  49.         PrintHelp();
  50.         return -1;
  51.     }
  52.  
  53.     /* Validate options */
  54.     int nChannelID = atoi(argv[1]);
  55.     std::string sServerIP(argv[2]);
  56.     int nPortBase = atoi(argv[3]);
  57.     int nPortCount = atoi(argv[4]);
  58.     int nConCount = atoi(argv[5]);
  59.     int nChangeCount = atoi(argv[6]);
  60.     int nSpeed = 2;
  61.     if ((nConCount < 1) || (nConCount > 32))
  62.     {
  63.         PrintHelp();
  64.         return -1;
  65.     }
  66.  
  67.     /* Greet user */
  68.     HSCLoggerInit(false, false, "qarva-ott-test");
  69.     printf("Sample is starting up...\n");
  70.  
  71.     /* Set Ports */
  72.     printf("Setting ports...\n");
  73.     QarvaDecoder_OptionsSetPorts(nPortBase, nPortCount);
  74.  
  75.     /* Add servers */
  76.     printf("Adding servers...\n");
  77.     for (int i=0; i<nConCount; i++)
  78.     {
  79.         QarvaDecoder_OptionsAddServer(sServerIP.c_str());
  80.     }
  81.  
  82.     /* Create decoder */
  83.     printf("Starting decoder...\n");
  84.     QarvaDecoder_StartQarvaOTT();
  85.     while(!QarvaDecoder_QarvaOTTInitialized()) sleep(1);
  86.     QarvaDecoder_SetLowLatencyMode(false);
  87.     uint64_t nLastCCTime = 0;
  88.     uint64_t nTime = 0;
  89.  
  90.         printf("Processing... 10%\r");
  91.     for(int i = 0; i < nChangeCount; i++)
  92.     {      
  93.             QarvaDecoder_TuneToChannel(nChannelID, nTime, 0, 0);
  94.             while(!QarvaDecoder_PESReady(true)) usleep(10000);
  95.  
  96.             uint64_t nPTS = QarvaDecoder_GetPESPTS(true);
  97.             QarvaDecoder_UpdateVisiblePTS(nPTS);
  98.  
  99.             uint64_t nCurCCTime = QarvaDecoder_GetLastCCTime();
  100.             nLastCCTime += nCurCCTime;
  101.     }
  102.  
  103.         printf("Processing... 50%\r");
  104.     uint64_t nAverageCCTime = nLastCCTime / nChangeCount;
  105.     nTime = HSC_TimeNow();
  106.     nTime -= 13000;
  107.  
  108.         for(int i = 0; i < nChangeCount; i++)
  109.         {
  110.                 QarvaDecoder_TuneToChannel(nChannelID, nTime, 0, 0);
  111.                 while(!QarvaDecoder_PESReady(true)) usleep(10000);
  112.  
  113.                 uint64_t nPTS = QarvaDecoder_GetPESPTS(true);
  114.                         QarvaDecoder_UpdateVisiblePTS(nPTS);
  115.  
  116.                 uint64_t nCurCCTime = QarvaDecoder_GetLastCCTime();
  117.         nLastCCTime += nCurCCTime;
  118.         }
  119.        
  120.         uint64_t nAverageTMTime = nLastCCTime / nChangeCount;
  121.     printf("Processing... 100%\n");
  122.         for(int i = 0; i < nChangeCount; i++)
  123.         {
  124.                 QarvaDecoder_SwitchToFF(nSpeed);
  125.                 while(!QarvaDecoder_PESReady(true)) usleep(10000);
  126.  
  127.                 uint64_t nPTS = QarvaDecoder_GetPESPTS(true);
  128.                         QarvaDecoder_UpdateVisiblePTS(nPTS);
  129.  
  130.                 uint64_t nCurCCTime = QarvaDecoder_GetLastCCTime();
  131.         nLastCCTime += nCurCCTime;
  132.         }
  133.  
  134.         uint64_t nAveragePBTime = nLastCCTime / nChangeCount;
  135.     printf("Average cc banchmark is: %llu\n", nAverageCCTime);
  136.         printf("Average timeshift banchmark is: %llu\n", nAverageTMTime);
  137.         printf("Average playback banchmark is: %llu      while speed : %d\n", nAveragePBTime, nSpeed);
  138.  
  139.  
  140.  
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement