Skip to main content
Skip table of contents

QuickMark forensic watermarking

The Nexguard library forensic watermarking tool is used to embed a unique, invisible serial number onto video/audio content. For more information about Nexguard, see:http://www.nexguard.com/company/inquiry/.

The minimum Android API for using the watermarking feature is 21 (Ver 5.0), and Android System Webview Ver 42 or higher to be installed on the device.

Prerequisites

A working watermark requires five parameters in order to work properly:

  • A Context to call NMPWatermark constructor
  • A valid NMPVideoView to bind the watermark to
  • A valid customer/system generated token of type String
  • A valid URL of type String
  • A valid Tenant name of type String

The last optional value is to set the ApiKey which is also of type String but this parameter is not required. As long as you have these values you will be able to create a working QuickMarkView .

Watermark is the core class of the watermarking function; its purpose is to take the above parameters passed by the user to create a new QuickMarkView and bind it to the provided NMPVideoView before starting the watermark playback. The class is also responsible for handling error message events and start/stopping the QuickMarkView whenever video playback is play/paused.

Error handling does not cover all the areas you might want from an error listener. Currently, the only cases that trigger an error are:

  • Null tenant value
  • Null token value
  • Null server url value
  • No server response
  • A url shorter than four characters

Most cases that should throw an error currently do not, such as an invalid url string or incorrect token value; at most you will have null/string length checks.

Example code

Attaching a Watermark is quite simple as long as you have the five parameters mentioned above. Since you require an NMPVideoView to bind/unbind the QuickMarkView, it is recommended to tie the watermark lifecycle to the NMPVideoView lifecycle. Below is a simple example of how you might implement an Watermark:

Create/Bind Watermark

JAVA
private NMPVideoView mNmpVideoView = null;
private Watermark mWatermark


// your function that creates/initialises your video view. once the video view is setup you can call watermark to bind it to the player
private void initVideoView(){
  mNmpVideoView = (NMPVideoView) xView.findViewById(R.id.nmpVideoView);
  //some video view initialising code
  ...
  startWatermark();
}

private void startWatermark(){

  mWatermark = new Watermark(getContext());
  mWatermark.addErrorListener(wErrorListener);
  mWatermark.addMessageListener(wMessageListener);
  mWatermark.setToken(WatermarkSettings.getToken());
  mWatermark.setApiKey(WatermarkSettings.getApiKey());
  mWatermark.setTenant(WatermarkSettings.getTenantId());
  mWatermark.setUrl(WatermarkSettings.getServerUrl());
  mWatermark.bind(mNmpVideoView);

}


/*
 *Create a watermark error listener to react to server watermark responses
 */
private WatermarkErrorListener wErrorListener = new WatermarkErrorListener() {
  @Override
  public void onError(WatermarkErrorId watermarkErrorId, String s) {
    switch (watermarkErrorId){
      case INVALID_TOKEN:
      case INVALID_URL:
      case INVALID_SERVER_ANSWER:
      case CANNOT_CONTACT_SERVER:
        yourErrorHandlingFunction(s);
        break;
      case NO_ERROR:
      default:
    noErrorFunction();
    }
  }
};


private WatermarkMessageListener wMessageListener = new WatermarkMessageListener() {
  @Override
  public void onMessage(String s) {
    NMPLog.d(TAG, "watermark message: " + s);
  yourMessageHandler(s);
  }
};

With this setup you should be able to create a working QuickMarkView. You can change how values are passed to mWatermark or change the values directly in WatermarkSettings to change which watermark is displayed.

Destroy/unbind watermark

Assuming that you constructed the Watermark as referenced above, the code below should be run when the video view is being destroyed to keep the watermark lifecycle matching with the video lifecycle.

JAVA
private void destroyVideoView(){


  //some video view destruction code
  ...
  stopWatermark();
  mWatermark = null;

}


/*
 * stop the watermark view and remove all listeners then unbind the NMPVideoView.
 */
private void stopWatermark(){
  if(mWatermark != null && mWatermark.boundPlayer() == mNmpVideoView) {
    mWatermark.removeErrorListener(wErrorListener);
    mWatermark.removeMessageListener(wMessageListener);
    mWatermark.unbind(mNmpVideoView);
  }
}


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.