github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/chat/attachments/preview_android.go (about)

     1  //go:build android
     2  // +build android
     3  
     4  package attachments
     5  
     6  import (
     7  	"bytes"
     8  	"io"
     9  
    10  	"github.com/keybase/client/go/chat/types"
    11  	"github.com/keybase/client/go/chat/utils"
    12  	"golang.org/x/net/context"
    13  )
    14  
    15  func previewVideo(ctx context.Context, log utils.DebugLabeler, src io.Reader,
    16  	basename string, nvh types.NativeVideoHelper) (res *PreviewRes, err error) {
    17  	defer log.Trace(ctx, &err, "previewVideo")()
    18  	dat, duration, err := nvh.ThumbnailAndDuration(ctx, basename)
    19  	if err != nil {
    20  		return res, err
    21  	}
    22  	log.Debug(ctx, "previewVideo: size: %d duration: %d", len(dat), duration)
    23  	if len(dat) == 0 {
    24  		log.Debug(ctx, "failed to generate preview from native, using blank image")
    25  		return previewVideoBlank(ctx, log, src, basename)
    26  	}
    27  	imagePreview, err := previewImage(ctx, log, bytes.NewReader(dat), basename, "image/jpeg")
    28  	if err != nil {
    29  		return res, err
    30  	}
    31  	return &PreviewRes{
    32  		Source:         imagePreview.Source,
    33  		ContentType:    "image/jpeg",
    34  		BaseWidth:      imagePreview.BaseWidth,
    35  		BaseHeight:     imagePreview.BaseHeight,
    36  		BaseDurationMs: duration,
    37  		PreviewHeight:  imagePreview.PreviewHeight,
    38  		PreviewWidth:   imagePreview.PreviewWidth,
    39  	}, nil
    40  }
    41  
    42  func HEICToJPEG(ctx context.Context, log utils.DebugLabeler, basename string) (dat []byte, err error) {
    43  	return nil, nil
    44  }