| 1 |
// Copyright 2025 Google LLC |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
// Code generated by protoc-gen-go_gapic. DO NOT EDIT. |
| 16 |
|
| 17 |
// [START videointelligence_v1p3beta1_generated_StreamingVideoIntelligenceService_StreamingAnnotateVideo_sync] |
| 18 |
|
| 19 |
package main |
| 20 |
|
| 21 |
import ( |
| 22 |
"context" |
| 23 |
"io" |
| 24 |
|
| 25 |
videointelligence "cloud.google.com/go/videointelligence/apiv1p3beta1" |
| 26 |
videointelligencepb "cloud.google.com/go/videointelligence/apiv1p3beta1/videointelligencepb" |
| 27 |
) |
| 28 |
|
| 29 |
func main() { |
| 30 |
ctx := context.Background() |
| 31 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 32 |
// It will require modifications to work: |
| 33 |
// - It may require correct/in-range values for request initialization. |
| 34 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 35 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 36 |
c, err := videointelligence.NewStreamingVideoIntelligenceClient(ctx) |
| 37 |
if err != nil { |
| 38 |
// TODO: Handle error. |
| 39 |
} |
| 40 |
defer c.Close() |
| 41 |
stream, err := c.StreamingAnnotateVideo(ctx) |
| 42 |
if err != nil { |
| 43 |
// TODO: Handle error. |
| 44 |
} |
| 45 |
go func() { |
| 46 |
reqs := []*videointelligencepb.StreamingAnnotateVideoRequest{ |
| 47 |
// TODO: Create requests. |
| 48 |
} |
| 49 |
for _, req := range reqs { |
| 50 |
if err := stream.Send(req); err != nil { |
| 51 |
// TODO: Handle error. |
| 52 |
} |
| 53 |
} |
| 54 |
stream.CloseSend() |
| 55 |
}() |
| 56 |
for { |
| 57 |
resp, err := stream.Recv() |
| 58 |
if err == io.EOF { |
| 59 |
break |
| 60 |
} |
| 61 |
if err != nil { |
| 62 |
// TODO: handle error. |
| 63 |
} |
| 64 |
// TODO: Use resp. |
| 65 |
_ = resp |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
// [END videointelligence_v1p3beta1_generated_StreamingVideoIntelligenceService_StreamingAnnotateVideo_sync] |