Class GsdkStreamView

    • Field Detail

      • SCALE_TYPE_FIT

        public static final int SCALE_TYPE_FIT
        Scales the stream so that its largest dimension spans the whole view; its smallest dimension is scaled accordingly to respect original aspect ratio, centered in the render zone; introduced padding, if any, is rendered according to padding fill configuration.

        Also corresponds to XML attribute fit in gsdk_scaleType.

        See Also:
        setScaleType(int), Constant Field Values
      • SCALE_TYPE_CROP

        public static final int SCALE_TYPE_CROP
        Scales the stream so that its smallest dimension spans the whole view; its largest dimension is scaled accordingly to respect original aspect ratio, and cropped to the render zone; no padding is introduced.

        Also corresponds to XML attribute crop in gsdk_scaleType.

        See Also:
        setScaleType(int), Constant Field Values
      • PADDING_FILL_BLUR_CROP

        public static final int PADDING_FILL_BLUR_CROP
        Padding introduced by fit scale type is filled by first rendering the current stream frame using crop scale type, blurred, then overlaying the scaled frame on top of it.

        Also corresponds to XML attribute blur_crop in gsdk_paddingFill.

        See Also:
        setPaddingFill(int), Constant Field Values
      • PADDING_FILL_BLUR_EXTEND

        public static final int PADDING_FILL_BLUR_EXTEND
        Padding introduced by fit scale type is filled by repeating current frame borders, blurred.

        Also corresponds to XML attribute blur_extend in gsdk_paddingFill.

        See Also:
        setPaddingFill(int), Constant Field Values
    • Constructor Detail

      • GsdkStreamView

        public GsdkStreamView​(@NonNull
                              Context context)
        Constructor.
        Parameters:
        context - android context
      • GsdkStreamView

        public GsdkStreamView​(@NonNull
                              Context context,
                              @Nullable
                              AttributeSet attrs)
        Constructor.
        Parameters:
        context - android context
        attrs - configured view attributes
      • GsdkStreamView

        public GsdkStreamView​(@NonNull
                              Context context,
                              @Nullable
                              AttributeSet attrs,
                              @AttrRes
                              int defStyleAttr)
        Constructor.
        Parameters:
        context - android context
        attrs - configured view attributes
        defStyleAttr - default style attribute, used to fallback on default attribute values
    • Method Detail

      • setScaleType

        public final void setScaleType​(int scaleType)
        Configures stream scale type.

        Scale type may also be configured using XML view attribute gsdk_scaleType.

        Parameters:
        scaleType - desired scale type
        See Also:
        getScaleType()
      • getScaleType

        public final int getScaleType()
        Returns configured stream scale type.
        Returns:
        configured scale type
        See Also:
        setScaleType(int)
      • setPaddingFill

        public final void setPaddingFill​(int paddingFill)
        Configures stream padding fill.

        Padding fill may also be configured using XML view attribute gsdk_paddingFill.

        Parameters:
        paddingFill - desired padding fill
        See Also:
        getPaddingFill()
      • getPaddingFill

        public final int getPaddingFill()
        Returns configured stream padding fill.
        Returns:
        configured padding fill
        See Also:
        setPaddingFill(int)
      • enableZebras

        public final void enableZebras​(boolean enable)
        Configures overexposure zebras rendering.

        Zebras rendering may also be configured using XML view attribute gsdk_zebrasEnabled.

        Parameters:
        enable - true to enable zebras rendering, false to disable it
        See Also:
        areZebrasEnabled()
      • areZebrasEnabled

        public final boolean areZebrasEnabled()
        Tells whether overexposure zebras rendering is enabled.
        Returns:
        true if zebras rendering is enabled, otherwise false
        See Also:
        enableZebras(boolean)
      • setZebraThreshold

        public final void setZebraThreshold​(double threshold)
        Configures overexposure zebra threshold.

        Zebra threshold may also be configured using XML view attribute gsdk_zebraThreshold.

        Parameters:
        threshold - desired zebra threshold
        See Also:
        areZebrasEnabled()
      • getZebraThreshold

        public final double getZebraThreshold()
        Returns configured overexposure zebra threshold.
        Returns:
        configured zebra threshold
        See Also:
        setZebraThreshold(double)
      • enableHistogram

        public final void enableHistogram​(boolean enable)
        Configure color histogram computation.
        Parameters:
        enable - true to enable histogram computation, false to disable it
        See Also:
        isHistogramEnabled()
      • isHistogramEnabled

        public final boolean isHistogramEnabled()
        Tells whether color histogram computation is enabled.
        Returns:
        true if histogram computation is enabled, otherwise false
      • setOverlayer

        public final void setOverlayer​(@Nullable
                                       Overlayer overlayer)
        Configures rendering overlayer.
        Parameters:
        overlayer - overlayer to configure, null to disable rendering overlay
      • setTextureLoader

        public final void setTextureLoader​(@Nullable
                                           TextureLoader textureLoader)
        Configures rendering texture loader.

        Note that configuring a texture loader will forcefully stop and restart rendering, when currently started.

        Parameters:
        textureLoader - texture loader to configure, null to disable texture loading
      • setStream

        public final void setStream​(@Nullable
                                    Stream stream)
        Attaches stream to be rendered.

        Client is responsible to detach (call setStream(null)) any stream before the view is disposed, otherwise, leak may occur.

        Parameters:
        stream - stream to render, null to detach stream
      • capture

        public final void capture​(@NonNull
                                  Bitmap bitmap,
                                  @NonNull
                                  GsdkStreamView.CaptureCallback callback)
        Captures latest rendered frame.

        Frame is captured to the provided bitmap, then forwarded asynchronously to the provided callback.

        Parameters:
        bitmap - bitmap to copy captured frame to; capture will be scaled tp match the width, height, and format of this bitmap
        callback - callback notified when the capture is complete, either successfully, or because of any error
      • capture

        public final void capture​(@NonNull
                                  GsdkStreamView.CaptureCallback callback)
        Captures latest rendered frame.

        Frame is captured to a bitmap with the same size as this view, configured as Bitmap.Config.ARGB_8888, then forwarded asynchronously to the provided callback.

        Parameters:
        callback - callback notified when the capture is complete, either successfully, or because of any error
      • setOnContentZoneChangeListener

        public final void setOnContentZoneChangeListener​(@Nullable
                                                         GsdkStreamView.OnContentZoneChangeListener listener)
        Registers a listener notified of content zone changes.

        Only one listener may be registered at a time; registering another listener automatically unregisters any previously registered one.

        Parameters:
        listener - listener to register, null to unregister any previously registered listener
        See Also:
        getContentZone()
      • getContentZone

        @NonNull
        public final Rect getContentZone()
        Gives access to rendered stream content zone.

        Content zone defines the area where actual stream content is rendered, excluding padding introduced by any configured scale type.

        Content zone is updated after each frame is rendered.

        Returns:
        current rendered stream content zone, empty when rendering is stopped and until first frame has been rendered
      • onStartRendering

        protected void onStartRendering()
        Notifies that rendering starts.

        Called on a dedicated GL rendering thread

        Subclasses may override this method to implement any custom behavior that must happen on the GL rendering thread when rendering starts.
        Default implementation does nothing.

      • onStopRendering

        protected void onStopRendering()
        Notifies that rendering stops.

        Called on a dedicated GL rendering thread

        Subclasses may override this method to implement any custom behavior that must happen on the GL rendering thread when rendering stops.
        Default implementation does nothing.