One, foreword

Early open source had a secret key generator, do more rough, but we also came close distance away from the real business application, in this time, the strong request of the user, the secret key authentication built this revision, to rewrite the original class, should be completed within a class is less than 300 lines of rewriting everything, and provide the complete generated secret key example and using the sample. In many commercial software, it is necessary to provide some versions that can be tested, so it is necessary to support the key mechanism to control. Throughout most of the trial software, the following mechanisms are basically adopted to control.

  • Remote networking activation, every time you start the network to check the use of time, etc., this method is perfect, the disadvantage is that the network can not be connected to the device to stop cooking.
  • More than half of the software uses this method. The disadvantage is that it cannot freely control other parameters of the software, such as the control of the number of devices added to the software.
  • Set a key file that controls parameters such as expiration time, quantity limit, and elapsed time, and send it to the user for the use of software. The disadvantage is that if only the expiration time is set, the user can change the computer time to obtain a longer use time, when the computer is not connected to the Internet. Therefore, it is generally recommended that a variety of control parameters are turned on, so that even if you change the computer time, there is a running time + the number of equipment control.

Key authentication function

  • Generate the secret key file.
  • Generate machine code files.
  • Obtain the CPU name, CPU number, mainboard number, and hard disk number.
  • Provide the function writeKey to write the contents of the secret key to the secret key file.
  • Provide the function checkTime to check the run time directly.
  • Provide the function checkCount to verify the number, which is usually called where the device is added.
  • Provide the function checkKey to verify the secret key file, passing in the secret key file and the operation key.
  • Provide the function checkLicense to verify that the machine code is correct.
  • Supports limits on the running date and time, the running time, and the number of devices.

Two, functions and features

(1) Software module

  1. Video surveillance module, various docking small form submodules, including equipment list, graphic alarm, window information, PTC control, preset position, cruise setting, equipment control, suspension map, web browsing, etc.
  2. Video playback module, including local playback, remote playback, device playback, picture playback, and video upload.
  3. Electronic map module, including picture map, online map, offline map, path planning and so on.
  4. Log query module, including local logs and device logs.
  5. System setting module, including system Settings (basic Settings, video parameters, database Settings, map configuration, serial port configuration, etc.), VCR management, camera management, polling configuration, user management, etc.

(2) Basic functions

  1. Support all kinds of video streams (RTSP, RTMP, HTTP, etc.), video files (MP4, RMVB, AVI, etc.), local USB camera playback.
  2. Supports multi-screen switching, including 1, 4, 6, 8, 9, 13, 16, 25, 36, 64 screen switching.
  3. Supports full-screen switching, including the right mouse button menu, toolbar buttons, and shortcut keys (Alt + Enter full-screen, esc exit full-screen).
  4. Supports video polling, including 1, 4, 9, and 16 screen polling. You can set polling groups (polling plan), polling interval, and bit stream types.
  5. Supports the ONVIF protocol, including device search, PTZ control, and device control (picture parameters, check time, system restart, and picture capture).
  6. Supports permission management. Different users have different permissions for modules, such as deleting logs and shutting down the system.
  7. Multiple databases are supported, including SQLite, mysql, SQLServer, PostgresQL, Oracle, and CNPC.
  8. You can set parameters such as resolution and frame rate for a local USB camera.
  9. All the docked modules automatically generate the corresponding menu to control the display and hide, right-click the title bar can be popup.
  10. You can display or hide all modules, reset the normal layout, or reset the full-screen layout.
  11. Double-click the device to display real-time preview videos, including picture maps, online maps, and offline maps.
  12. Drag the camera node to the corresponding form to play the video. You can also drag the local file to play the video directly.
  13. You can delete a video from the right mouse button, close the hover bar, or drag it outside the video monitoring panel.
  14. The device button on the picture map can be dragged freely to automatically save the location information. On the Baidu map, you can click to obtain the latitude and longitude information to update the device location.
  15. Any channel in the form of the video monitoring panel supports drag exchange and instant response.
  16. Encapsulating Baidu map, view switching, motion trajectory, device point, click the mouse to obtain latitude and longitude.
  17. Double click the node, drag the node, drag the form to change the position and other operations, are automatically updated and saved the last play address, the next software open automatic application.
  18. Lower right volume bar control, automatically hidden when losing focus, volume band mute icon.
  19. Support video capture, you can specify a single or all channel capture, the bottom toolbar also has a screenshot button.
  20. Supports automatic hiding of the mouse pointer and automatic full screen after timeout.
  21. Support onVIF PTZ control, can move PTZ camera up, down, left and right, including reset and focus adjustment.
  22. Support any ONVIF camera, including but not limited to Hikon, Dahua, Yusee, Tiandi weiye, Huawei, etc.
  23. Can save the video, can select the storage or single file storage, optional storage interval.
  24. The video stream communication mode can be set to TCP + UDP, and the video decoding mode can be set to speed first, quality first, balance, etc.
  25. You can set the software name in Chinese, English, and LOGO.
  26. The stored video files can be exported to a specified directory and uploaded to the server in batches.

(3) Features

  1. The main interface adopts the mode of docked form, and various components are added in the form of small modules, and any modules can be customized.
  2. The docking module can be dragged to any position to embed and hover, support maximum full screen, support multi-screen.
  3. Dual layout file storage mechanism, normal mode, full screen mode correspond to different layout scheme, automatic switching and saving, such as the full screen mode can highlight several modules transparent display in the specified position, more science fiction sense of modernization.
  4. The original ONVIF protocol mechanism, using the underlying protocol parsing (UDP broadcast search + HTTP request execution command) is more lightweight, easy to learn and expand, do not rely on any third-party components such as GSOAP.
  5. Original data import and export mechanism, cross-platform does not depend on any components, instantaneous data export.
  6. Built-in multiple original components, the universe value is super awesome, It includes data import and export components (export to XLS, PDF, print), database components (database management thread, automatic data cleaning thread, universal paging, data request, etc.), map components, video monitoring components, file multi-threaded transceiver components, ONVIF communication components, general browser kernel components, etc.
  7. Custom information box, error box, query box, and message box (in various formats) in the lower right corner.
  8. Exquisite skin peels, up to 17 sets of skin styles can be changed at will, all styles are unified, including menu, etc.
  9. Multiple buttons can be added to the video control hover bar, and buttons can also be added to the small toolbar at the bottom of the monitoring interface.
  10. Double click the camera node to automatically play the video, double click the node to automatically add the video, will automatically jump to the next, double click the parent node to automatically add all the videos under this node. Primary stream and substream are optional.
  11. VCR management and camera management: You can add, delete, modify, import or export printed information. The new device information is immediately applied to generate a tree list without restarting the system.
  12. Optional a variety of kernel free switching, FFMPEG, VLC, MPV, etc., can be set in pro. It is recommended to use FFMPEG, the most cross-platform, default to provide a good Linux and MAC platform compiled library.
  13. Support hard decoding, can set the hard decoding type (QSV, DXVA2, D3D11VA, etc.).
  14. Opengl rendering video by default, ultra low CPU resource occupation, support yuYV and NV12 two formats, very cow force.
  15. Highly customizable, users can easily derive their own functions on this basis, such as adding custom modules, operating modes, robot monitoring, uav monitoring, excavator monitoring, etc.
  16. Support XP, Win7, Win10, Linux, MAC, a variety of domestic systems (UOS, Kirin, Galaxy, etc.), embedded Linux and other systems.
  17. Complete comments, clear project structure, super detailed complete use of the development manual, down to the function of each code file, continuous iterations.

Three, experience address

  1. Experience address: pan.baidu.com/s/1d7TH_GEY… Extract code: 01JF File name: bin_video_system.zip.
  2. Domestic website: gitee.com/feiyangqing…
  3. International site: github.com/feiyangqing…
  4. Profile: blog.csdn.net/feiyangqing…
  5. Zhihu homepage: www.zhihu.com/people/feiy…
  6. Online documentation: feiyangqingyun. Gitee. IO/qwidgetdemo…

Four, the effect diagram

5. Core code

void AppKey::checkKey(const QString &fileName, char keyCode)
{
    // Check whether the key file exists. If the key file does not exist, copy it from the resource file and set the write permission for the file
    QFile keyFile(fileName);
    if(! keyFile.exists() || keyFile.size() = =0) {
        QMessageBox::critical(0."Error"."Key file lost, please contact supplier!");
        exit(0);
    }

    // Read the key file
    keyFile.open(QFile::ReadOnly);
    keyData = keyFile.readLine(a); keyFile.close(a);// Decrypt the ciphertext from the registration code file
    keyData = getXorEncryptDecrypt(keyData, keyCode);
    QStringList data = keyData.split("|");
    if (data.count() != 6) {
        QMessageBox::critical(0."Error"."Registration code file corrupted, program will be automatically closed!");
        exit(0);
    }

    // Retrieve the contents of the corresponding items one by one
    keyUseDate = (data.at(0) = ="1");
    keyDate = data.at(1);
    keyUseRun = (data.at(2) = ="1");
    keyRun = data.at(3).toInt(a); keyUseCount = (data.at(4) = ="1");
    keyCount = data.at(5).toInt(a);// If the time limit is enabled
    if (keyUseDate) {
        QString nowDate = QDate::currentDate().toString("yyyy-MM-dd");
        if (nowDate > keyDate) {
            QMessageBox::critical(0."Error"."The software has expired, please contact the vendor to update the registration code!");
            exit(0); }}// If runtime display is enabled
    if (keyUseRun) {
        timer->start();
    }
}

bool AppKey::checkLicense(const QString &fileName)
{
    QFile keyFile(fileName);
    if(! keyFile.exists() || keyFile.size() = =0) {
        QMessageBox::critical(0."Error"."Key file lost, please contact supplier!");
        exit(0);
    }

    // Read the key file
    keyFile.open(QFile::ReadOnly);
    keyData = keyFile.readLine(a); keyFile.close(a);// Get the machine code
    QString cpuid = getCpuId(a); QString number =getBoardNum(a); QStringList keys;int count1 = cpuid.count(a);int count2 = number.count(a);int count = qMin(count1, count2);
    for (int i = 0; i < count; i++) {
        keys << QString("% 1% 2").arg(cpuid.at(i)).arg(number.at(i));
    }

    // Capitalize the key and remove the Spaces
    QString key = keys.join("").toUpper(a);if (key.contains("")) {
        QStringList list;
        for (int i = 0; i < key.count(a); i++) {if (key.at(i) ! =' ') { list << key.at(i); } } key = list.join(""); QByteArray Result = QCryptographicHash::hash(key.tolatin1 (), QCryptographicHash::Md5).toHex().toUpper();if(result ! = keyData) {QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(key);
        QString info = QString("Key file error, please contact supplier! Machine code has been copied automatically! \n machine code: %1").arg(key);
        QMessageBox::critical(0."Error", info);
        exit(0); }}Copy the code