cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

display-sync.c (1868B)


      1/*
      2 * Licensed to the Apache Software Foundation (ASF) under one
      3 * or more contributor license agreements.  See the NOTICE file
      4 * distributed with this work for additional information
      5 * regarding copyright ownership.  The ASF licenses this file
      6 * to you under the Apache License, Version 2.0 (the
      7 * "License"); you may not use this file except in compliance
      8 * with the License.  You may obtain a copy of the License at
      9 *
     10 *   http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing,
     13 * software distributed under the License is distributed on an
     14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     15 * KIND, either express or implied.  See the License for the
     16 * specific language governing permissions and limitations
     17 * under the License.
     18 */
     19
     20#include "config.h"
     21#include "display.h"
     22#include "layer.h"
     23#include "log.h"
     24#include "video.h"
     25
     26#include <guacamole/client.h>
     27#include <guacamole/timestamp.h>
     28
     29#include <assert.h>
     30#include <stdlib.h>
     31
     32int guacenc_display_sync(guacenc_display* display, guac_timestamp timestamp) {
     33
     34    /* Verify timestamp is not decreasing */
     35    if (timestamp < display->last_sync) {
     36        guacenc_log(GUAC_LOG_WARNING, "Decreasing sync timestamp");
     37        return 1;
     38    }
     39
     40    /* Update timestamp of display */
     41    display->last_sync = timestamp;
     42
     43    /* Flatten display to default layer */
     44    if (guacenc_display_flatten(display))
     45        return 1;
     46
     47    /* Retrieve default layer (guaranteed to not be NULL) */
     48    guacenc_layer* def_layer = guacenc_display_get_layer(display, 0);
     49    assert(def_layer != NULL);
     50
     51    /* Update video timeline */
     52    if (guacenc_video_advance_timeline(display->output, timestamp))
     53        return 1;
     54
     55    /* Prepare frame for write upon next flush */
     56    guacenc_video_prepare_frame(display->output, def_layer->frame);
     57    return 0;
     58
     59}
     60