Vips.Source (original) (raw)

Class

VipsSource

Description [src]

class Vips.Source : Vips.Connection
{
  gboolean decode,
  gboolean have_tested_seek,
  gboolean is_pipe,
  gint64 read_position,
  gint64 length
}

A VipsSource provides a unified interface for reading, seeking, and mapping data, regardless of the underlying source type.

This source can originate from something like a socket, file or memory area.

During the header phase, we save data from unseekable sources in a buffer so readers can rewind and read again. We don’t buffer data during the decode stage.

Constructors

Functions

Instance methods

vips_source_decode

Signal the end of header read and the start of the pixel decode phase. After this, you can no longer seek on this source.

vips_source_is_file

Test if this source is a simple file with support for seek. Named pipes, for example, will fail this test. If TRUE, you can usevips_connection_filename() to find the filename.

vips_source_is_mappable

Some sources can be efficiently mapped into memory. You can still use vips_source_map() if this function returns FALSE, but it will be slow.

vips_source_length

Return the length in bytes of the source. Unseekable sources, for example pipes, will have to be read entirely into memory before the length can be found, so this operation can take a long time.

vips_source_map

Map the source entirely into memory and return a pointer to the start. If length is non-NULL, the source size is written to it.

vips_source_map_blob

Just like vips_source_map(), but return a VipsBlob containing the pointer. source will stay alive as long as the result is alive.

vips_source_minimise

Minimise the source. As many resources as can be safely removed are removed. Use vips_source_unminimise() to restore the source if you wish to use it again.

vips_source_read

Read up to length bytes from source and store the bytes in buffer. Return the number of bytes actually read. If all bytes have been read from the file, return 0.

vips_source_seek

Move the file read position. You can’t call this after pixel decode starts. The arguments are exactly as lseek().

vips_source_sniff

Return a pointer to the first few bytes of the file. If the file is too short, return NULL.

vips_source_sniff_at_most

Attempt to sniff at most length bytes from the start of the source. A pointer to the bytes is returned in data. The number of bytes actually read is returned — it may be less than length if the file is shorter thanlength. A negative number indicates a read error.

vips_source_unminimise

Restore the source after minimisation. This is called at the start of every source method, so loaders should not usually need this.

Methods inherited from GObject (43)

Please see GObject for a full list of methods.

Properties

Signals

Signals inherited from VipsObject (4)
VipsObject::close

The ::close signal is emitted once during object close. The object is dying and may not work.

VipsObject::postbuild

The ::postbuild signal is emitted once just after successful object construction. Return non-zero to cause object construction to fail.

VipsObject::postclose

The ::postclose signal is emitted once after object close. The object pointer is still valid, but nothing else.

VipsObject::preclose

The ::preclose signal is emitted once just before object close starts. The object is still alive.

Signals inherited from GObject (1)
GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

Class structure

struct VipsSourceClass {
  VipsConnectionClass parent_class;
  gint64 (* read) (
    VipsSource* source,
    void* buffer,
    size_t length
  );
  gint64 (* seek) (
    VipsSource* source,
    gint64 offset,
    int whence
  );
  
}

No description available.

Class members

parent_class: VipsConnectionClass

No description available.

read: gint64 (* read) ( VipsSource* source, void* buffer, size_t length )

No description available.

seek: gint64 (* seek) ( VipsSource* source, gint64 offset, int whence )

No description available.

Virtual methods

Vips.SourceClass.read

Read up to length bytes from source and store the bytes in buffer. Return the number of bytes actually read. If all bytes have been read from the file, return 0.