play

package
v0.0.0-...-683b059 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Overview

Package play provides common code for playing videos on Chrome.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorDistance

func ColorDistance(a, b color.Color) int

ColorDistance returns the maximum absolute difference between each component of a and b. Both a and b are assumed to be RGBA colors.

func ColorSamplingPointsForStillColorsVideo

func ColorSamplingPointsForStillColorsVideo(videoW, videoH int) map[string]image.Point

ColorSamplingPointsForStillColorsVideo returns a map of points that are considered to be interesting in the rendering of the still-colors-*.mp4 test videos. The key in the map is a name for the corresponding point. There are two categories of points:

  • Outer corners: the four absolute corners of the video offset by 1 to ignore acceptable color blending artifacts on the edges. However, the outer bottom-right is not offset because we never expect blending artifacts there.
  • Inner corners: 4 stencils (one for each corner of the video). Each stencil is composed of 4 sampling points arranged as a square. The expectation is that for each stencil, 3 of its points fall on the interior border of the test video while the remaining point falls inside one of the color rectangles. This helps us detect undesired stretching/shifting/rotation/mirroring. The naming convention for each point of a stencil is as follows:

    inner_Y_X_00: the corner of the stencil closest to the Y-X corner of the video. inner_Y_X_01: the corner of the stencil that's in the interior X border of the video. inner_Y_X_10: the corner of the stencil that's in the interior Y border of the video. inner_Y_X_11: the only corner of the stencil that's not on the border strip.

    For example, the top-right corner of the test video looks like this:

    MMMMMMMMMMMMMMMM MMMMMMMMMM2MMM0M MMMMMMMMMMMMMMMM 3 M1M MMM

    Where 'M' is the magenta interior border. So the names of each of the points 0, 1, 2, 3 are:

    0: inner_top_right_00 1: inner_top_right_01 2: inner_top_right_10 3: inner_top_right_11

func DRMDataFiles

func DRMDataFiles() []string

DRMDataFiles returns a list of required files for tests that play DRM videos.

func MSEDataFiles

func MSEDataFiles() []string

MSEDataFiles returns a list of required files for tests that play MSE videos.

func TestPlay

func TestPlay(ctx context.Context, s *testing.State, cs ash.ConnSource, cr *chrome.Chrome,
	filename string, videotype VideoType, mode VerifyHWAcceleratorMode, unmutePlayer bool) error

TestPlay checks that the video file named filename can be played using Chrome. videotype represents a type of a given video. If it is MSEVideo, filename is a name of MPD file. If mode is VerifyHWAcceleratorUsed, this function also checks if hardware accelerator was used.

func TestPlayAndScreenshot

func TestPlayAndScreenshot(ctx context.Context, s *testing.State, tconn *chrome.TestConn, cs ash.ConnSource, filename, refFilename string) error

TestPlayAndScreenshot plays the filename video, switches it to full screen mode, takes a screenshot and analyzes the resulting image to sample the colors of a few interesting points and compare them against expectations. The expectations are defined by refFilename which is a PNG file corresponding to the ideally rendered video frame in the absence of scaling or artifacts.

Caveat: this test does not disable night light. Night light doesn't seem to affect the output of the screenshot tool, but this might not hold in the future in case we decide to apply night light at compositing time if the hardware does not support the color transform matrix.

func TestSeek

func TestSeek(ctx context.Context, httpHandler http.Handler, cs ash.ConnSource, filename, outDir string, numSeeks int) error

TestSeek checks that the video file named filename can be seeked around. It will play the video and seek randomly into it numSeeks times.

Types

type VerifyHWAcceleratorMode

type VerifyHWAcceleratorMode int

VerifyHWAcceleratorMode represents a mode of TestPlay.

const (
	// NoVerifyHWAcceleratorUsed is a mode that plays a video without verifying
	// hardware accelerator usage.
	NoVerifyHWAcceleratorUsed VerifyHWAcceleratorMode = iota
	// VerifyHWAcceleratorUsed is a mode that verifies a video is played using a
	// hardware accelerator.
	VerifyHWAcceleratorUsed
	// VerifyNoHWAcceleratorUsed is a mode that verifies a video is not played
	// using a hardware accelerator, i.e. it's using software decoding.
	VerifyNoHWAcceleratorUsed
	// VerifyHWDRMUsed is a mode that verifies a video is played using a hardware
	// accelerator with HW DRM protection.
	VerifyHWDRMUsed
)

type VideoType

type VideoType int

VideoType represents a type of video played in TestPlay.

const (
	// NormalVideo represents a normal video. (i.e. non-MSE video.)
	NormalVideo VideoType = iota
	// MSEVideo represents a video requiring Media Source Extensions (MSE).
	MSEVideo
	// DRMVideo represents a video requiring Digital Rights Management (DRM).
	DRMVideo
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL